thys2/ClosedFormsBounds.thy
author Chengsong
Wed, 09 Mar 2022 17:33:08 +0000
changeset 444 a7e98deebb5c
child 445 e072cfc2f2ee
permissions -rw-r--r--
restructured sizebound proof
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     1
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     2
theory ClosedFormsBounds
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     3
  imports "GeneralRegexBound" "ClosedForms"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     4
begin
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     5
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     6
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     7
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     8
lemma alts_closed_form_bounded: shows
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     9
"\<forall>r \<in> set rs. \<forall>s. rsize(rders_simp r s ) \<le> N \<Longrightarrow> 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    10
rsize (rders_simp (RALTS rs ) s) \<le> max (Suc ( N * (card (sizeNregex N)))) (rsize (RALTS rs) )"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    11
  apply(induct s)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    12
  apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    13
  apply(insert alts_closed_form_variant)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    14
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    15
  
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    16
  sorry
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    17
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    18
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    19
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    20
lemma star_closed_form_bounded_by_rdistinct_list_estimate:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    21
  shows "rsize (rsimp ( RALTS ( (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) )
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    22
         (star_updates s r0 [[c]]) ) ))) \<le>
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    23
        Suc (sum_list (map rsize (rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) )
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    24
         (star_updates s r0 [[c]]) ) {})  ) )"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    25
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    26
  sorry
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    27
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    28
lemma distinct_list_rexp_up_to_certain_size_bouded_by_set_enumerating_up_to_that_size:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    29
  shows "\<forall>r\<in> set rs. (rsize r ) \<le> N \<Longrightarrow> sum_list (map rsize (rdistinct rs {})) \<le>
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    30
         (card (sizeNregex N))* N"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    31
  sorry
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    32
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    33
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    34
lemma star_control_bounded:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    35
  shows "\<forall>s. rsize (rders_simp r0 s) \<le> N \<Longrightarrow>        
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    36
      (sum_list (map rsize (rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    37
         (star_updates s r0 [[c]]) ) {})  ) ) \<le> 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    38
(card (sizeNregex (Suc (N + rsize (RSTAR r0))))) * (Suc (N + rsize (RSTAR r0)))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    39
"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    40
  sorry
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    41
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    42
lemma star_control_variant:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    43
  assumes "\<forall>s. rsize (rders_simp r0 s) \<le> N"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    44
  shows"Suc 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    45
      (sum_list (map rsize (rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0)) 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    46
          (star_updates list r0 [[a]])) {}))) 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    47
\<le>  (Suc (card (sizeNregex (Suc (N + rsize (RSTAR r0))))) * Suc (N + rsize (RSTAR r0))) "
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    48
  apply(subgoal_tac    "(sum_list (map rsize (rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0)) 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    49
          (star_updates list r0 [[a]])) {}))) 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    50
\<le>  ( (card (sizeNregex (Suc (N + rsize (RSTAR r0))))) * Suc (N + rsize (RSTAR r0))) ")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    51
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    52
  using assms star_control_bounded apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    53
  by simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    54
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    55
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    56
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    57
lemma star_closed_form_bounded:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    58
  shows "\<forall>s. rsize (rders_simp r0 s) \<le> N \<Longrightarrow>
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    59
              rsize (rders_simp (RSTAR r0) s) \<le> 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    60
max (   (Suc (card (sizeNregex (Suc (N + rsize (RSTAR r0))))) * (Suc (N + rsize (RSTAR r0)))))   (rsize (RSTAR r0))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    61
  apply(case_tac s)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    62
  apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    63
  apply(subgoal_tac " rsize (rders_simp (RSTAR r0) (a # list)) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    64
rsize (rsimp ( RALTS ( (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) ) (star_updates list r0 [[a]]) ) )))") 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    65
   prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    66
  using star_closed_form apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    67
  apply(subgoal_tac "rsize (rsimp (
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    68
 RALTS ( (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) ) (star_updates list    r0 [[a]]) ) ))) 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    69
\<le>         Suc (sum_list (map rsize (rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) )
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    70
         (star_updates list r0 [[a]]) ) {})  ) )")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    71
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    72
  using star_closed_form_bounded_by_rdistinct_list_estimate apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    73
  apply(subgoal_tac "Suc (sum_list 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    74
                 (map rsize
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    75
                   (rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0)) (star_updates list r0 [[a]])) {}))) 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    76
\<le>  (Suc (card (sizeNregex (Suc (N + rsize (RSTAR r0))))) * Suc (N + rsize (RSTAR r0)))  ")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    77
  apply auto[1]
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    78
  using star_control_variant by blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    79
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    80
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    81
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    82
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    83
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    84
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    85
lemma seq_list_estimate_control: shows 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    86
" rsize (rsimp (RALTS (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1))))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    87
           \<le> Suc (sum_list (map rsize (rdistinct (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1)) {})))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    88
  
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    89
  sorry
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    90
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    91
lemma seq_estimate_bounded: 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    92
  assumes "\<forall>s. rsize (rders_simp r1 s) \<le> N1" and "\<forall>s. rsize (rders_simp r2 s) \<le> N2"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    93
  shows
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    94
"Suc (sum_list (map rsize (rdistinct (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1)) {}))) \<le>
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    95
 Suc (Suc (N1 + (rsize r2)) + (N2 * card (sizeNregex N2)))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    96
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    97
  sorry
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    98
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    99
lemma seq_closed_form_bounded: shows
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   100
"\<lbrakk>\<forall>s. rsize (rders_simp r1 s) \<le> N1 ; \<forall>s. rsize (rders_simp r2 s) \<le> N2\<rbrakk> \<Longrightarrow>
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   101
rsize (rders_simp (RSEQ r1 r2) s) \<le> 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   102
max (Suc (Suc (N1 + (rsize r2)) + (N2 * card (sizeNregex N2)))) (rsize (RSEQ r1 r2)) "
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   103
  apply(case_tac s)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   104
  apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   105
  apply(subgoal_tac " (rders_simp (RSEQ r1 r2) s) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   106
rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) # (map (rders_simp r2) (vsuf s r1))))")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   107
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   108
  using seq_closed_form_variant apply blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   109
  apply(subgoal_tac "rsize (rsimp (RALTS (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1))))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   110
                    \<le>
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   111
Suc (sum_list (map rsize (rdistinct (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1)) {})))")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   112
  apply(subgoal_tac "Suc (sum_list (map rsize (rdistinct (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1)) {})))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   113
\<le> Suc (Suc (N1 + (rsize r2)) + (N2 * card (sizeNregex N2)))")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   114
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   115
  using seq_estimate_bounded apply blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   116
   apply(subgoal_tac "rsize (rders_simp (RSEQ r1 r2) s) \<le> Suc (Suc (N1 + rsize r2) + N2 * card (sizeNregex N2))")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   117
  using le_max_iff_disj apply blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   118
   apply auto[1]
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   119
  using seq_list_estimate_control by presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   120
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   121
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   122
lemma rders_simp_bounded: shows
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   123
"\<exists>N. \<forall>s. rsize (rders_simp r s) \<le> N"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   124
  apply(induct r)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   125
       apply(rule_tac x = "Suc 0 " in exI)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   126
  using three_easy_cases0 apply force
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   127
  using three_easy_cases1 apply blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   128
  using three_easy_casesC apply blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   129
  using seq_closed_form_bounded apply blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   130
  apply (metis alts_closed_form_bounded size_list_estimation')
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   131
  using star_closed_form_bounded by blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   132
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   133
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   134
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   135
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   136
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   137
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   138
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   139
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   140
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   141
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   142
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   143
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   144
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   145
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   146
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   147
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   148
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   149
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   150
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   151
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   152
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   153
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   154
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   155
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   156
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   157
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   158
(*Obsolete materials*)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   159
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   160
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   161
lemma rexp_size_induct:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   162
  shows "\<And>N r x5 a list.
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   163
       \<lbrakk> rsize r = Suc N; r = RALTS x5;
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   164
        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"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   165
  apply(rule_tac x = "rsize a" in exI)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   166
  apply(rule_tac x = "rsize (RALTS list)" in exI)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   167
  apply(subgoal_tac "rsize a \<ge> 1")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   168
   prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   169
  using One_nat_def non_zero_size apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   170
  apply(subgoal_tac "rsize (RALTS list) \<ge> 1 ")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   171
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   172
  using size_geq1 apply blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   173
  apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   174
  done
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   175
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   176
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   177
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   178
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   179
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   180
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   181
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   182
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   183
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   184
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   185
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   186
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   187
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   188
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   189
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   190
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   191
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   192
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   193
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   194
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   195
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   196
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   197
lemma star_update_case1:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   198
  shows "rnullable (rders_simp r s) \<Longrightarrow> star_update c r (s # Ss) = (s @ [c]) # [c] # (star_update c r Ss)"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   199
  
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   200
  by force
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   201
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   202
lemma star_update_case2:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   203
  shows "\<not>rnullable (rders_simp r s) \<Longrightarrow> star_update c r (s # Ss) = (s @ [c]) # (star_update c r Ss)"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   204
  by simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   205
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   206
lemma bubble_break: shows "rflts [r, RZERO] = rflts [r]"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   207
  apply(case_tac r)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   208
       apply simp+
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   209
  done
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   210
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   211
lemma rsimp_alts_idem_aux1:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   212
  shows "rsimp_ALTs (rdistinct (rflts [rsimp a]) {}) = rsimp (RALTS [a])"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   213
  by force
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   214
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   215
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   216
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   217
lemma rsimp_alts_idem_aux2:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   218
  shows "rsimp a = rsimp (RALTS [a])"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   219
  apply(simp)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   220
  apply(case_tac "rsimp a")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   221
       apply simp+
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   222
  apply (metis no_alt_short_list_after_simp no_further_dB_after_simp)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   223
  by simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   224
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   225
lemma rsimp_alts_idem:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   226
  shows "rsimp (rsimp_ALTs (a # as)) = rsimp (rsimp_ALTs (a # [(rsimp (rsimp_ALTs as))] ))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   227
  apply(induct as)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   228
   apply(subgoal_tac "rsimp (rsimp_ALTs [a, rsimp (rsimp_ALTs [])]) = rsimp (rsimp_ALTs [a, RZERO])")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   229
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   230
    apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   231
  using bubble_break rsimp_alts_idem_aux2 apply auto[1]
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   232
  apply(case_tac as)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   233
   apply(subgoal_tac "rsimp_ALTs( aa # as) = aa")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   234
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   235
    apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   236
  using head_one_more_simp apply fastforce
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   237
  apply(subgoal_tac "rsimp_ALTs (aa # as) = RALTS (aa # as)")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   238
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   239
  
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   240
  using rsimp_ALTs.simps(3) apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   241
  
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   242
  apply(simp only:)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   243
  apply(subgoal_tac "rsimp_ALTs (a # aa # aaa # list) = RALTS (a # aa # aaa # list)")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   244
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   245
  using rsimp_ALTs.simps(3) apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   246
  apply(simp only:)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   247
  apply(subgoal_tac "rsimp_ALTs [a, rsimp (RALTS (aa # aaa # list))] = RALTS (a # [rsimp (RALTS (aa # aaa # list))])")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   248
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   249
  
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   250
  using rsimp_ALTs.simps(3) apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   251
  apply(simp only:)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   252
  using simp_flatten2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   253
  apply(subgoal_tac " rsimp (RALT a (rsimp (RALTS (aa # aaa # list))))  =  rsimp (RALT a ((RALTS (aa # aaa # list)))) ")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   254
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   255
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   256
  apply (metis head_one_more_simp list.simps(9) rsimp.simps(2))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   257
  apply (simp only:)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   258
  done
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   259
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   260
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   261
lemma rsimp_alts_idem2:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   262
  shows "rsimp (rsimp_ALTs (a # as)) = rsimp (rsimp_ALTs ((rsimp a) # [(rsimp (rsimp_ALTs as))] ))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   263
  using head_one_more_simp rsimp_alts_idem by auto
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   264
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   265
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   266
lemma evolution_step1:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   267
  shows "rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   268
        (rsimp_ALTs
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   269
          (rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)) # map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   270
         rsimp 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   271
        (rsimp_ALTs
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   272
          (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)))]))   "
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   273
  using rsimp_alts_idem by auto
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   274
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   275
lemma evolution_step2:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   276
  assumes " rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   277
       rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   278
  shows "rsimp 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   279
        (rsimp_ALTs 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   280
          (rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)) # map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   281
                 rsimp 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   282
        (rsimp_ALTs
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   283
          (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)))]))  "
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   284
  by (simp add: assms rsimp_alts_idem)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   285
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   286
lemma rsimp_seq_aux1:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   287
  shows "r = RONE \<and> r2 = RSTAR r0 \<Longrightarrow> rsimp_SEQ r r2 = r2"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   288
  apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   289
  done
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   290
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   291
lemma multiple_alts_simp_flatten:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   292
  shows "rsimp (RALT (RALT r1 r2) (rsimp_ALTs rs)) = rsimp (RALTS (r1 # r2 # rs))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   293
  by (metis Cons_eq_appendI append_self_conv2 rsimp_ALTs.simps(2) rsimp_ALTs.simps(3) rsimp_alts_idem simp_flatten)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   294
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   295
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   296
lemma evo3_main_aux1:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   297
  shows "rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   298
            (RALT (RALT (RSEQ (rsimp (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   299
              (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))) =
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   300
           rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   301
            (RALTS
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   302
              (RSEQ (rders_simp r (a @ [x])) (RSTAR r) #
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   303
               RSEQ (rders_simp r [x]) (RSTAR r) # map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   304
  apply(subgoal_tac "rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   305
            (RALT (RALT (RSEQ (rsimp (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   306
              (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))) =
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   307
rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   308
            (RALT (RALT (RSEQ ( (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   309
              (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))) ")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   310
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   311
   apply (simp add: rsimp_idem)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   312
  apply (simp only:)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   313
  apply(subst multiple_alts_simp_flatten)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   314
  by simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   315
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   316
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   317
lemma evo3_main_nullable:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   318
  shows "
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   319
\<And>a Ss.
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   320
       \<lbrakk>rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   321
        rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)));
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   322
        rders_simp r a \<noteq> RONE; rders_simp r a \<noteq> RZERO; rnullable (rders_simp r a)\<rbrakk>
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   323
       \<Longrightarrow> rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   324
            (rsimp_ALTs
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   325
              [rder x (RSEQ (rders_simp r a) (RSTAR r)),
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   326
               rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))]) =
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   327
           rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r (a # Ss))))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   328
  apply(subgoal_tac "rder x (RSEQ (rders_simp r a) (RSTAR r)) 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   329
                   = RALT (RSEQ (rder x (rders_simp r a)) (RSTAR r)) (RSEQ (rder x r) (RSTAR r))")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   330
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   331
   apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   332
  apply(simp only:)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   333
  apply(subgoal_tac "star_update x r (a # Ss) = (a @ [x]) # [x] # (star_update x r Ss)")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   334
   prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   335
  using star_update_case1 apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   336
  apply(simp only:)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   337
  apply(subst List.list.map(2))+
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   338
  apply(subgoal_tac "rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   339
            (rsimp_ALTs
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   340
              [RALT (RSEQ (rder x (rders_simp r a)) (RSTAR r)) (RSEQ (rder x r) (RSTAR r)),
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   341
               rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))]) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   342
rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   343
            (RALTS
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   344
              [RALT (RSEQ (rder x (rders_simp r a)) (RSTAR r)) (RSEQ (rder x r) (RSTAR r)),
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   345
               rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))])")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   346
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   347
  using rsimp_ALTs.simps(3) apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   348
  apply(simp only:)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   349
  apply(subgoal_tac " rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   350
            (rsimp_ALTs
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   351
              (rsimp_SEQ (rders_simp r (a @ [x])) (RSTAR r) #
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   352
               rsimp_SEQ (rders_simp r [x]) (RSTAR r) # map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))) 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   353
= 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   354
 rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   355
            (RALTS
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   356
              (rsimp_SEQ (rders_simp r (a @ [x])) (RSTAR r) #
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   357
               rsimp_SEQ (rders_simp r [x]) (RSTAR r) # map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   358
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   359
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   360
  using rsimp_ALTs.simps(3) apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   361
  apply (simp only:)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   362
  apply(subgoal_tac " rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   363
            (RALT (RALT (RSEQ (rder x (rders_simp r a)) (RSTAR r)) (RSEQ ( (rder x r)) (RSTAR r)))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   364
              (rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))))) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   365
             rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   366
            (RALT (RALT (RSEQ (rsimp (rder x (rders_simp r a))) (RSTAR r)) (RSEQ (rsimp (rder x r)) (RSTAR r)))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   367
              (rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))))")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   368
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   369
   apply (simp add: rsimp_idem)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   370
  apply(simp only:)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   371
  apply(subgoal_tac "             rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   372
            (RALT (RALT (RSEQ (rsimp (rder x (rders_simp r a))) (RSTAR r)) (RSEQ (rsimp (rder x r)) (RSTAR r)))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   373
              (rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))))) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   374
             rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   375
            (RALT (RALT (RSEQ (rsimp (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   376
              (rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))))")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   377
   prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   378
  using rders_simp_append rders_simp_one_char rsimp_idem apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   379
  apply(simp only:)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   380
  apply(subgoal_tac " rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   381
            (RALTS
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   382
              (rsimp_SEQ (rders_simp r (a @ [x])) (RSTAR r) #
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   383
               rsimp_SEQ (rders_simp r [x]) (RSTAR r) # map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   384
 rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   385
            (RALTS
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   386
              (RSEQ (rders_simp r (a @ [x])) (RSTAR r) #
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   387
               RSEQ (rders_simp r [x]) (RSTAR r) # map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   388
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   389
  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)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   390
  apply(simp only:)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   391
  apply(subgoal_tac "      rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   392
            (RALT (RALT (RSEQ (rsimp (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   393
              (rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))))) =
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   394
     rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   395
            (RALT (RALT (RSEQ (rsimp (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   396
              ( (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))))  ")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   397
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   398
  using rsimp_idem apply force
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   399
  apply(simp only:)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   400
  using evo3_main_aux1 by blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   401
  
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   402
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   403
lemma evo3_main_not1:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   404
  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)"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   405
  by fastforce
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   406
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   407
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   408
lemma evo3_main_not2:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   409
  shows "\<not>rnullable (rders_simp r a) \<Longrightarrow>  rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   410
            (rsimp_ALTs
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   411
              (rder x (RSEQ (rders_simp r a) (RSTAR r)) # rs)) = rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   412
            (rsimp_ALTs
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   413
              ((RSEQ (rders_simp r (a @ [x])) (RSTAR r)) # rs))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   414
  by (simp add: rders_simp_append rsimp_alts_idem2 rsimp_idem)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   415
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   416
lemma evo3_main_not3:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   417
  shows "rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   418
            (rsimp_ALTs
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   419
              (rsimp_SEQ r1 (RSTAR r) # rs)) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   420
         rsimp (rsimp_ALTs
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   421
              (RSEQ r1 (RSTAR r) # rs))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   422
  by (metis idiot2 rrexp.distinct(9) rsimp.simps(1) rsimp.simps(3) rsimp.simps(4) rsimp.simps(6) rsimp_alts_idem rsimp_alts_idem2)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   423
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   424
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   425
lemma evo3_main_notnullable:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   426
  shows "\<And>a Ss.
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   427
       \<lbrakk>rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   428
        rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)));
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   429
        rders_simp r a \<noteq> RONE; rders_simp r a \<noteq> RZERO; \<not>rnullable (rders_simp r a)\<rbrakk>
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   430
       \<Longrightarrow> rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   431
            (rsimp_ALTs
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   432
              [rder x (RSEQ (rders_simp r a) (RSTAR r)),
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   433
               rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))]) =
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   434
           rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r (a # Ss))))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   435
  apply(subst star_update_case2)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   436
   apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   437
  apply(subst List.list.map(2))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   438
  apply(subst evo3_main_not2)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   439
   apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   440
  apply(subst evo3_main_not3)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   441
  using rsimp_alts_idem by presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   442
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   443
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   444
lemma evo3_aux2:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   445
  shows "rders_simp r a = RONE \<Longrightarrow> rsimp_SEQ (rders_simp (rders_simp r a) [x]) (RSTAR r) = RZERO"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   446
  by simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   447
lemma evo3_aux3:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   448
  shows "rsimp (rsimp_ALTs (RZERO # rs)) = rsimp (rsimp_ALTs rs)"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   449
  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)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   450
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   451
lemma evo3_aux4:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   452
  shows " rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   453
            (rsimp_ALTs
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   454
              [RSEQ (rder x r) (RSTAR r),
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   455
               rsimp (rsimp_ALTs rs)]) =
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   456
           rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   457
            (rsimp_ALTs
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   458
              (rsimp_SEQ (rders_simp r [x]) (RSTAR r) # rs))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   459
  by (metis rders_simp_one_char rsimp.simps(1) rsimp.simps(6) rsimp_alts_idem rsimp_alts_idem2)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   460
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   461
lemma evo3_aux5:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   462
  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)"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   463
  using idiot2 by blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   464
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   465
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   466
lemma evolution_step3:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   467
  shows" \<And>a Ss.
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   468
       rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   469
       rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))) \<Longrightarrow>
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   470
       rsimp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   471
        (rsimp_ALTs
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   472
          [rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)),
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   473
           rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))]) =
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   474
       rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r (a # Ss))))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   475
  apply(case_tac "rders_simp r a = RONE")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   476
   apply(subst rsimp_seq_aux1)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   477
    apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   478
  apply(subst rder.simps(6))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   479
   apply(subgoal_tac "rnullable (rders_simp r a)")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   480
    prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   481
  using rnullable.simps(2) apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   482
   apply(subst star_update_case1)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   483
    apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   484
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   485
   apply(subst List.list.map)+
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   486
  apply(subst rders_simp_append)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   487
   apply(subst evo3_aux2)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   488
    apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   489
   apply(subst evo3_aux3)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   490
   apply(subst evo3_aux4)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   491
   apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   492
  apply(case_tac "rders_simp r a = RZERO")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   493
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   494
   apply (simp add: rsimp_alts_idem2)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   495
   apply(subgoal_tac "rders_simp r (a @ [x]) = RZERO")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   496
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   497
  using rder.simps(1) rders_simp_append rders_simp_one_char rsimp.simps(3) apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   498
  using rflts.simps(2) rsimp.simps(3) rsimp_SEQ.simps(1) apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   499
  apply(subst evo3_aux5)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   500
   apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   501
  apply(case_tac "rnullable (rders_simp r a) ")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   502
  using evo3_main_nullable apply blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   503
  using evo3_main_notnullable apply blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   504
  done
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   505
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   506
(*
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   507
proof (prove)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   508
goal (1 subgoal):
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   509
 1. map f (a # s) = f a # map f s 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   510
Auto solve_direct: the current goal can be solved directly with
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   511
  HOL.nitpick_simp(115): map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   512
  List.list.map(2): map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   513
  List.list.simps(9): map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   514
*)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   515
lemma starseq_list_evolution:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   516
  fixes  r :: rrexp and Ss :: "char list list" and x :: char 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   517
  shows "rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss) ) =
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   518
         rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))  )"   
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   519
  apply(induct Ss)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   520
   apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   521
  apply(subst List.list.map(2))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   522
  apply(subst evolution_step2)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   523
   apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   524
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   525
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   526
  sorry
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   527
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   528
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   529
lemma star_seqs_produce_star_seqs:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   530
  shows "rsimp (rsimp_ALTs (map (rder x \<circ> (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   531
       = rsimp (rsimp_ALTs (map ( (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r)))) Ss))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   532
  by (meson comp_apply)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   533
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   534
lemma map_der_lambda_composition:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   535
  shows "map (rder x) (map (\<lambda>s. f s) Ss) = map (\<lambda>s. (rder x (f s))) Ss"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   536
  by force
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   537
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   538
lemma ralts_vs_rsimpalts:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   539
  shows "rsimp (RALTS rs) = rsimp (rsimp_ALTs rs)"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   540
  by (metis evo3_aux3 rsimp_ALTs.simps(2) rsimp_ALTs.simps(3) simp_flatten2)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   541
  
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   542
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   543
lemma linearity_of_list_of_star_or_starseqs: 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   544
  fixes r::rrexp and Ss::"char list list" and x::char
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   545
  shows "\<exists>Ssa. rsimp (rder x (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))) =
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   546
                 rsimp (RALTS ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ssa)))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   547
  apply(subst rder_rsimp_ALTs_commute)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   548
  apply(subst map_der_lambda_composition)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   549
  using starseq_list_evolution
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   550
  apply(rule_tac x = "star_update x r Ss" in exI)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   551
  apply(subst ralts_vs_rsimpalts)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   552
  by simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   553
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   554
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   555
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   556
(*certified correctness---does not depend on any previous sorry*)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   557
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));
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   558
        xs @ [x] \<noteq> []; xs \<noteq> []\<rbrakk> \<Longrightarrow>
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   559
     \<exists>Ss. rders_simp (RSTAR r ) (xs @ [x]) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   560
        rsimp (RALTS (map (\<lambda>s1. (rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) ) Ss) )"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   561
  apply(subgoal_tac  "\<exists>Ss. rders_simp (RSTAR r) xs = rsimp (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   562
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   563
  apply blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   564
  apply(erule exE)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   565
  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))))")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   566
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   567
  using rders_simp_append
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   568
  using rders_simp_one_char apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   569
  apply(rule_tac x= "Ss" in exI)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   570
  apply(subgoal_tac " rsimp (rder x (rsimp (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   571
                       rsimp (rsimp (rder x (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))))")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   572
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   573
  using inside_simp_removal rsimp_idem apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   574
  apply(subgoal_tac "rsimp (rsimp (rder x (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))) =
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   575
                     rsimp (rsimp (RALTS (map (rder x) (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))))")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   576
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   577
  using rder.simps(4) apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   578
  apply(subgoal_tac "rsimp (rsimp (RALTS (map (rder x) (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))) =
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   579
                     rsimp (rsimp (RALTS (map (\<lambda>s1. (rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r)))) Ss)))")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   580
   apply (metis rsimp_idem)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   581
  by (metis map_der_lambda_composition)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   582
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   583
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   584
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   585
end