thys2/ClosedFormsBounds.thy
author Chengsong
Thu, 10 Mar 2022 15:53:46 +0000
changeset 446 0a94fd47b792
parent 445 e072cfc2f2ee
child 447 7fb1e3dd5ae6
permissions -rw-r--r--
before repair
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"
445
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
    31
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    32
  sorry
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    33
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    34
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    35
lemma star_control_bounded:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    36
  shows "\<forall>s. rsize (rders_simp r0 s) \<le> N \<Longrightarrow>        
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    37
      (sum_list (map rsize (rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    38
         (star_updates s r0 [[c]]) ) {})  ) ) \<le> 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    39
(card (sizeNregex (Suc (N + rsize (RSTAR r0))))) * (Suc (N + rsize (RSTAR r0)))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    40
"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    41
  sorry
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    42
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    43
lemma star_control_variant:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    44
  assumes "\<forall>s. rsize (rders_simp r0 s) \<le> N"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    45
  shows"Suc 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    46
      (sum_list (map rsize (rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0)) 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    47
          (star_updates list r0 [[a]])) {}))) 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    48
\<le>  (Suc (card (sizeNregex (Suc (N + rsize (RSTAR r0))))) * Suc (N + rsize (RSTAR r0))) "
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    49
  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
    50
          (star_updates list r0 [[a]])) {}))) 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    51
\<le>  ( (card (sizeNregex (Suc (N + rsize (RSTAR r0))))) * Suc (N + rsize (RSTAR r0))) ")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    52
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    53
  using assms star_control_bounded apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    54
  by simp
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
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    58
lemma star_closed_form_bounded:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    59
  shows "\<forall>s. rsize (rders_simp r0 s) \<le> N \<Longrightarrow>
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    60
              rsize (rders_simp (RSTAR r0) s) \<le> 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    61
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
    62
  apply(case_tac s)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    63
  apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    64
  apply(subgoal_tac " rsize (rders_simp (RSTAR r0) (a # list)) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    65
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
    66
   prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    67
  using star_closed_form apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    68
  apply(subgoal_tac "rsize (rsimp (
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    69
 RALTS ( (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) ) (star_updates list    r0 [[a]]) ) ))) 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    70
\<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
    71
         (star_updates list r0 [[a]]) ) {})  ) )")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    72
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    73
  using star_closed_form_bounded_by_rdistinct_list_estimate apply presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    74
  apply(subgoal_tac "Suc (sum_list 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    75
                 (map rsize
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    76
                   (rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0)) (star_updates list r0 [[a]])) {}))) 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    77
\<le>  (Suc (card (sizeNregex (Suc (N + rsize (RSTAR r0))))) * Suc (N + rsize (RSTAR r0)))  ")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    78
  apply auto[1]
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    79
  using star_control_variant by blast
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
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    86
lemma seq_list_estimate_control: shows 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    87
" rsize (rsimp (RALTS (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1))))
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    88
           \<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
    89
  
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    90
  sorry
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    91
446
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
    92
lemma rdistinct_equality1:
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
    93
  shows "a \<notin> ss \<Longrightarrow> rdistinct (a  # rs) ss = a # rdistinct rs (insert a ss) "
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
    94
  by auto
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
    95
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
    96
lemma larger_acc_smaller_distinct_res0:
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
    97
  shows " ss \<subseteq> SS \<Longrightarrow> sum_list (map rsize (rdistinct rs SS)) \<le> sum_list (map rsize (rdistinct rs ss))"
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
    98
  apply(induct rs arbitrary: ss SS)
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
    99
  apply simp
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   100
  apply(case_tac "a \<in> ss")
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   101
   apply(subgoal_tac "a \<in> SS")
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   102
    apply simp
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   103
   apply blast
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   104
  apply(case_tac "a \<in> SS")
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   105
   apply simp
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   106
   apply(subgoal_tac "insert a ss \<subseteq> SS")
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   107
    apply simp
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   108
  apply (simp add: trans_le_add2)
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   109
  apply blast
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   110
  apply(simp)
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   111
  apply(subgoal_tac "insert a ss \<subseteq> insert a SS")
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   112
   apply blast
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   113
  by blast
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   114
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   115
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   116
lemma larger_acc_smaller_distinct_res:
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   117
  shows " (sum_list (map rsize (rdistinct rs ss))) \<ge> (sum_list (map rsize (rdistinct rs (insert a ss))))"
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   118
  sorry
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   119
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   120
lemma size_list_triangle1:
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   121
  shows  "sum_list (map rsize (a # (rdistinct as ss))) \<ge> rsize a + sum_list (map rsize (rdistinct as (insert a ss)))"
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   122
  by (simp add: larger_acc_smaller_distinct_res)
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   123
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   124
445
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   125
lemma triangle_inequality_distinct:
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   126
  shows "sum_list (map rsize (rdistinct (a # rs) ss)) \<le> rsize a + (sum_list (map rsize (rdistinct rs ss)))"
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   127
  apply(case_tac "a \<in> ss")
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   128
   apply simp
446
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   129
  apply(subst rdistinct_equality1)
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   130
   apply simp
0a94fd47b792 before repair
Chengsong
parents: 445
diff changeset
   131
  using size_list_triangle1 by auto
445
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   132
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   133
lemma same_regex_property_after_map:
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   134
  shows "\<forall>s. P (f r2 s) \<Longrightarrow> \<forall>r \<in> set  (map (f r2) Ss). P r"
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   135
  by auto
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   136
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   137
lemma same_property_after_distinct:
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   138
  shows " \<forall>r \<in> set  (map (f r2) Ss). P r \<Longrightarrow> \<forall>r \<in> set (rdistinct (map (f r2) Ss) xset). P r"
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   139
  apply(induct Ss arbitrary: xset)
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   140
   apply simp
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   141
  by auto
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   142
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   143
lemma same_regex_property_after_distinct:
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   144
  shows "\<forall>s. P (f r2 s) \<Longrightarrow> \<forall>r \<in> set (rdistinct (map (f r2) Ss) xset). P r"
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   145
  apply(rule same_property_after_distinct)
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   146
  apply(rule same_regex_property_after_map)
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   147
  by simp
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   148
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   149
lemma map_ders_is_list_of_ders:
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   150
  shows  "\<forall>s. rsize (rders_simp r2 s) \<le> N2 \<Longrightarrow>
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   151
\<forall>r \<in> set (rdistinct (map (rders_simp r2) Ss) {}). rsize r \<le> N2"
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   152
  apply(rule same_regex_property_after_distinct)
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   153
  by simp
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   154
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   155
lemma seq_estimate_bounded: 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   156
  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
   157
  shows
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   158
"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
   159
 Suc (Suc (N1 + (rsize r2)) + (N2 * card (sizeNregex N2)))"
445
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   160
  apply(subgoal_tac " (sum_list (map rsize (rdistinct (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1)) {}))) \<le>
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   161
  (Suc (N1 + (rsize r2)) + (N2 * card (sizeNregex N2)))")
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   162
   apply force
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   163
  apply(subgoal_tac " (sum_list (map rsize (rdistinct (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1)) {}))) \<le>
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   164
                      (rsize (RSEQ (rders_simp r1 s) r2)) + (sum_list (map rsize (rdistinct (map (rders_simp r2) (vsuf s r1)) {})) )")
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   165
  prefer 2
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   166
  using triangle_inequality_distinct apply blast
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   167
  apply(subgoal_tac " sum_list (map rsize (rdistinct (map (rders_simp r2) (vsuf s r1)) {})) \<le> N2 * card (sizeNregex N2) ")
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   168
   apply(subgoal_tac "rsize (RSEQ (rders_simp r1 s) r2) \<le> Suc (N1 + rsize r2)")
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   169
    apply linarith
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   170
   apply (simp add: assms(1))
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   171
  apply(subgoal_tac "\<forall>r \<in> set (rdistinct (map (rders_simp r2) (vsuf s r1)) {}). rsize r \<le> N2")
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   172
  apply (metis (no_types, opaque_lifting) assms(2) distinct_list_rexp_up_to_certain_size_bouded_by_set_enumerating_up_to_that_size ex_map_conv mult.commute)
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   173
  using assms(2) map_ders_is_list_of_ders by blast
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   174
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   175
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   176
lemma seq_closed_form_bounded: shows
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   177
"\<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
   178
rsize (rders_simp (RSEQ r1 r2) s) \<le> 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   179
max (Suc (Suc (N1 + (rsize r2)) + (N2 * card (sizeNregex N2)))) (rsize (RSEQ r1 r2)) "
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   180
  apply(case_tac s)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   181
  apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   182
  apply(subgoal_tac " (rders_simp (RSEQ r1 r2) s) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   183
rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) # (map (rders_simp r2) (vsuf s r1))))")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   184
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   185
  using seq_closed_form_variant apply blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   186
  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
   187
                    \<le>
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   188
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
   189
  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
   190
\<le> Suc (Suc (N1 + (rsize r2)) + (N2 * card (sizeNregex N2)))")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   191
  prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   192
  using seq_estimate_bounded apply blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   193
   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
   194
  using le_max_iff_disj apply blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   195
   apply auto[1]
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   196
  using seq_list_estimate_control by presburger
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   197
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   198
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   199
lemma rders_simp_bounded: shows
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   200
"\<exists>N. \<forall>s. rsize (rders_simp r s) \<le> N"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   201
  apply(induct r)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   202
       apply(rule_tac x = "Suc 0 " in exI)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   203
  using three_easy_cases0 apply force
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   204
  using three_easy_cases1 apply blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   205
  using three_easy_casesC apply blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   206
  using seq_closed_form_bounded apply blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   207
  apply (metis alts_closed_form_bounded size_list_estimation')
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   208
  using star_closed_form_bounded by blast
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   209
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   210
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   211
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   212
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   213
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
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   218
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   219
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   220
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   221
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   222
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   223
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   224
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   225
(*Obsolete materials*)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   226
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   227
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   228
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
   229
end