444
|
1 |
|
|
2 |
theory ClosedFormsBounds
|
|
3 |
imports "GeneralRegexBound" "ClosedForms"
|
|
4 |
begin
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
lemma alts_closed_form_bounded: shows
|
|
9 |
"\<forall>r \<in> set rs. \<forall>s. rsize(rders_simp r s ) \<le> N \<Longrightarrow>
|
|
10 |
rsize (rders_simp (RALTS rs ) s) \<le> max (Suc ( N * (card (sizeNregex N)))) (rsize (RALTS rs) )"
|
|
11 |
apply(induct s)
|
|
12 |
apply simp
|
|
13 |
apply(insert alts_closed_form_variant)
|
|
14 |
|
|
15 |
|
|
16 |
sorry
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
lemma star_closed_form_bounded_by_rdistinct_list_estimate:
|
|
21 |
shows "rsize (rsimp ( RALTS ( (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) )
|
|
22 |
(star_updates s r0 [[c]]) ) ))) \<le>
|
|
23 |
Suc (sum_list (map rsize (rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) )
|
|
24 |
(star_updates s r0 [[c]]) ) {}) ) )"
|
|
25 |
|
|
26 |
sorry
|
|
27 |
|
|
28 |
lemma distinct_list_rexp_up_to_certain_size_bouded_by_set_enumerating_up_to_that_size:
|
|
29 |
shows "\<forall>r\<in> set rs. (rsize r ) \<le> N \<Longrightarrow> sum_list (map rsize (rdistinct rs {})) \<le>
|
|
30 |
(card (sizeNregex N))* N"
|
445
|
31 |
|
444
|
32 |
sorry
|
|
33 |
|
|
34 |
|
|
35 |
lemma star_control_bounded:
|
|
36 |
shows "\<forall>s. rsize (rders_simp r0 s) \<le> N \<Longrightarrow>
|
|
37 |
(sum_list (map rsize (rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0))
|
|
38 |
(star_updates s r0 [[c]]) ) {}) ) ) \<le>
|
|
39 |
(card (sizeNregex (Suc (N + rsize (RSTAR r0))))) * (Suc (N + rsize (RSTAR r0)))
|
|
40 |
"
|
|
41 |
sorry
|
|
42 |
|
|
43 |
lemma star_control_variant:
|
|
44 |
assumes "\<forall>s. rsize (rders_simp r0 s) \<le> N"
|
|
45 |
shows"Suc
|
|
46 |
(sum_list (map rsize (rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0))
|
|
47 |
(star_updates list r0 [[a]])) {})))
|
|
48 |
\<le> (Suc (card (sizeNregex (Suc (N + rsize (RSTAR r0))))) * Suc (N + rsize (RSTAR r0))) "
|
|
49 |
apply(subgoal_tac "(sum_list (map rsize (rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0))
|
|
50 |
(star_updates list r0 [[a]])) {})))
|
|
51 |
\<le> ( (card (sizeNregex (Suc (N + rsize (RSTAR r0))))) * Suc (N + rsize (RSTAR r0))) ")
|
|
52 |
prefer 2
|
|
53 |
using assms star_control_bounded apply presburger
|
|
54 |
by simp
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
lemma star_closed_form_bounded:
|
|
59 |
shows "\<forall>s. rsize (rders_simp r0 s) \<le> N \<Longrightarrow>
|
|
60 |
rsize (rders_simp (RSTAR r0) s) \<le>
|
|
61 |
max ( (Suc (card (sizeNregex (Suc (N + rsize (RSTAR r0))))) * (Suc (N + rsize (RSTAR r0))))) (rsize (RSTAR r0))"
|
|
62 |
apply(case_tac s)
|
|
63 |
apply simp
|
|
64 |
apply(subgoal_tac " rsize (rders_simp (RSTAR r0) (a # list)) =
|
|
65 |
rsize (rsimp ( RALTS ( (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) ) (star_updates list r0 [[a]]) ) )))")
|
|
66 |
prefer 2
|
|
67 |
using star_closed_form apply presburger
|
|
68 |
apply(subgoal_tac "rsize (rsimp (
|
|
69 |
RALTS ( (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) ) (star_updates list r0 [[a]]) ) )))
|
|
70 |
\<le> Suc (sum_list (map rsize (rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) )
|
|
71 |
(star_updates list r0 [[a]]) ) {}) ) )")
|
|
72 |
prefer 2
|
|
73 |
using star_closed_form_bounded_by_rdistinct_list_estimate apply presburger
|
|
74 |
apply(subgoal_tac "Suc (sum_list
|
|
75 |
(map rsize
|
|
76 |
(rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0)) (star_updates list r0 [[a]])) {})))
|
|
77 |
\<le> (Suc (card (sizeNregex (Suc (N + rsize (RSTAR r0))))) * Suc (N + rsize (RSTAR r0))) ")
|
|
78 |
apply auto[1]
|
|
79 |
using star_control_variant by blast
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
lemma seq_list_estimate_control: shows
|
|
87 |
" rsize (rsimp (RALTS (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1))))
|
|
88 |
\<le> Suc (sum_list (map rsize (rdistinct (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1)) {})))"
|
|
89 |
|
|
90 |
sorry
|
|
91 |
|
445
|
92 |
lemma triangle_inequality_distinct:
|
|
93 |
shows "sum_list (map rsize (rdistinct (a # rs) ss)) \<le> rsize a + (sum_list (map rsize (rdistinct rs ss)))"
|
|
94 |
apply(arbitrary: ss)
|
|
95 |
apply simp
|
|
96 |
apply(case_tac "a \<in> ss")
|
|
97 |
apply simp
|
|
98 |
|
|
99 |
sorry
|
|
100 |
|
|
101 |
lemma same_regex_property_after_map:
|
|
102 |
shows "\<forall>s. P (f r2 s) \<Longrightarrow> \<forall>r \<in> set (map (f r2) Ss). P r"
|
|
103 |
by auto
|
|
104 |
|
|
105 |
lemma same_property_after_distinct:
|
|
106 |
shows " \<forall>r \<in> set (map (f r2) Ss). P r \<Longrightarrow> \<forall>r \<in> set (rdistinct (map (f r2) Ss) xset). P r"
|
|
107 |
apply(induct Ss arbitrary: xset)
|
|
108 |
apply simp
|
|
109 |
by auto
|
|
110 |
|
|
111 |
lemma same_regex_property_after_distinct:
|
|
112 |
shows "\<forall>s. P (f r2 s) \<Longrightarrow> \<forall>r \<in> set (rdistinct (map (f r2) Ss) xset). P r"
|
|
113 |
apply(rule same_property_after_distinct)
|
|
114 |
apply(rule same_regex_property_after_map)
|
|
115 |
by simp
|
|
116 |
|
|
117 |
lemma map_ders_is_list_of_ders:
|
|
118 |
shows "\<forall>s. rsize (rders_simp r2 s) \<le> N2 \<Longrightarrow>
|
|
119 |
\<forall>r \<in> set (rdistinct (map (rders_simp r2) Ss) {}). rsize r \<le> N2"
|
|
120 |
apply(rule same_regex_property_after_distinct)
|
|
121 |
by simp
|
|
122 |
|
444
|
123 |
lemma seq_estimate_bounded:
|
|
124 |
assumes "\<forall>s. rsize (rders_simp r1 s) \<le> N1" and "\<forall>s. rsize (rders_simp r2 s) \<le> N2"
|
|
125 |
shows
|
|
126 |
"Suc (sum_list (map rsize (rdistinct (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1)) {}))) \<le>
|
|
127 |
Suc (Suc (N1 + (rsize r2)) + (N2 * card (sizeNregex N2)))"
|
445
|
128 |
apply(subgoal_tac " (sum_list (map rsize (rdistinct (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1)) {}))) \<le>
|
|
129 |
(Suc (N1 + (rsize r2)) + (N2 * card (sizeNregex N2)))")
|
|
130 |
apply force
|
|
131 |
apply(subgoal_tac " (sum_list (map rsize (rdistinct (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1)) {}))) \<le>
|
|
132 |
(rsize (RSEQ (rders_simp r1 s) r2)) + (sum_list (map rsize (rdistinct (map (rders_simp r2) (vsuf s r1)) {})) )")
|
|
133 |
prefer 2
|
|
134 |
using triangle_inequality_distinct apply blast
|
|
135 |
apply(subgoal_tac " sum_list (map rsize (rdistinct (map (rders_simp r2) (vsuf s r1)) {})) \<le> N2 * card (sizeNregex N2) ")
|
|
136 |
apply(subgoal_tac "rsize (RSEQ (rders_simp r1 s) r2) \<le> Suc (N1 + rsize r2)")
|
|
137 |
apply linarith
|
|
138 |
apply (simp add: assms(1))
|
|
139 |
apply(subgoal_tac "\<forall>r \<in> set (rdistinct (map (rders_simp r2) (vsuf s r1)) {}). rsize r \<le> N2")
|
|
140 |
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)
|
|
141 |
using assms(2) map_ders_is_list_of_ders by blast
|
444
|
142 |
|
|
143 |
|
|
144 |
lemma seq_closed_form_bounded: shows
|
|
145 |
"\<lbrakk>\<forall>s. rsize (rders_simp r1 s) \<le> N1 ; \<forall>s. rsize (rders_simp r2 s) \<le> N2\<rbrakk> \<Longrightarrow>
|
|
146 |
rsize (rders_simp (RSEQ r1 r2) s) \<le>
|
|
147 |
max (Suc (Suc (N1 + (rsize r2)) + (N2 * card (sizeNregex N2)))) (rsize (RSEQ r1 r2)) "
|
|
148 |
apply(case_tac s)
|
|
149 |
apply simp
|
|
150 |
apply(subgoal_tac " (rders_simp (RSEQ r1 r2) s) =
|
|
151 |
rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) # (map (rders_simp r2) (vsuf s r1))))")
|
|
152 |
prefer 2
|
|
153 |
using seq_closed_form_variant apply blast
|
|
154 |
apply(subgoal_tac "rsize (rsimp (RALTS (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1))))
|
|
155 |
\<le>
|
|
156 |
Suc (sum_list (map rsize (rdistinct (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1)) {})))")
|
|
157 |
apply(subgoal_tac "Suc (sum_list (map rsize (rdistinct (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1)) {})))
|
|
158 |
\<le> Suc (Suc (N1 + (rsize r2)) + (N2 * card (sizeNregex N2)))")
|
|
159 |
prefer 2
|
|
160 |
using seq_estimate_bounded apply blast
|
|
161 |
apply(subgoal_tac "rsize (rders_simp (RSEQ r1 r2) s) \<le> Suc (Suc (N1 + rsize r2) + N2 * card (sizeNregex N2))")
|
|
162 |
using le_max_iff_disj apply blast
|
|
163 |
apply auto[1]
|
|
164 |
using seq_list_estimate_control by presburger
|
|
165 |
|
|
166 |
|
|
167 |
lemma rders_simp_bounded: shows
|
|
168 |
"\<exists>N. \<forall>s. rsize (rders_simp r s) \<le> N"
|
|
169 |
apply(induct r)
|
|
170 |
apply(rule_tac x = "Suc 0 " in exI)
|
|
171 |
using three_easy_cases0 apply force
|
|
172 |
using three_easy_cases1 apply blast
|
|
173 |
using three_easy_casesC apply blast
|
|
174 |
using seq_closed_form_bounded apply blast
|
|
175 |
apply (metis alts_closed_form_bounded size_list_estimation')
|
|
176 |
using star_closed_form_bounded by blast
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
(*Obsolete materials*)
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
end
|