| author | huffman |
| Tue, 08 Mar 2005 00:45:58 +0100 | |
| changeset 15594 | 36f3e7ef3cb6 |
| parent 15570 | 8d8c70b41bab |
| child 16220 | fd980649c4b2 |
| permissions | -rw-r--r-- |
| 3071 | 1 |
(* Title: HOLCF/IOA/meta_theory/Sequence.ML |
| 3275 | 2 |
ID: $Id$ |
| 15594 | 3 |
Author: Olaf Mller |
| 3071 | 4 |
|
| 12218 | 5 |
Theorems about Sequences over flat domains with lifted elements. |
| 3071 | 6 |
*) |
7 |
||
| 3656 | 8 |
|
| 3071 | 9 |
Addsimps [andalso_and,andalso_or]; |
10 |
||
11 |
(* ----------------------------------------------------------------------------------- *) |
|
12 |
||
13 |
section "recursive equations of operators"; |
|
14 |
||
15 |
(* ---------------------------------------------------------------- *) |
|
16 |
(* Map *) |
|
17 |
(* ---------------------------------------------------------------- *) |
|
18 |
||
| 10835 | 19 |
Goal "Map f$UU =UU"; |
| 4098 | 20 |
by (simp_tac (simpset() addsimps [Map_def]) 1); |
| 3071 | 21 |
qed"Map_UU"; |
22 |
||
| 10835 | 23 |
Goal "Map f$nil =nil"; |
| 4098 | 24 |
by (simp_tac (simpset() addsimps [Map_def]) 1); |
| 3071 | 25 |
qed"Map_nil"; |
26 |
||
| 10835 | 27 |
Goal "Map f$(x>>xs)=(f x) >> Map f$xs"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
28 |
by (simp_tac (simpset() addsimps [Map_def, Consq_def,flift2_def]) 1); |
| 3071 | 29 |
qed"Map_cons"; |
30 |
||
31 |
(* ---------------------------------------------------------------- *) |
|
32 |
(* Filter *) |
|
33 |
(* ---------------------------------------------------------------- *) |
|
34 |
||
| 10835 | 35 |
Goal "Filter P$UU =UU"; |
| 4098 | 36 |
by (simp_tac (simpset() addsimps [Filter_def]) 1); |
| 3071 | 37 |
qed"Filter_UU"; |
38 |
||
| 10835 | 39 |
Goal "Filter P$nil =nil"; |
| 4098 | 40 |
by (simp_tac (simpset() addsimps [Filter_def]) 1); |
| 3071 | 41 |
qed"Filter_nil"; |
42 |
||
| 10835 | 43 |
Goal "Filter P$(x>>xs)= (if P x then x>>(Filter P$xs) else Filter P$xs)"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
44 |
by (simp_tac (simpset() addsimps [Filter_def, Consq_def,flift2_def,If_and_if]) 1); |
| 3071 | 45 |
qed"Filter_cons"; |
46 |
||
47 |
(* ---------------------------------------------------------------- *) |
|
48 |
(* Forall *) |
|
49 |
(* ---------------------------------------------------------------- *) |
|
50 |
||
| 5068 | 51 |
Goal "Forall P UU"; |
| 4098 | 52 |
by (simp_tac (simpset() addsimps [Forall_def,sforall_def]) 1); |
| 3071 | 53 |
qed"Forall_UU"; |
54 |
||
| 5068 | 55 |
Goal "Forall P nil"; |
| 4098 | 56 |
by (simp_tac (simpset() addsimps [Forall_def,sforall_def]) 1); |
| 3071 | 57 |
qed"Forall_nil"; |
58 |
||
| 5068 | 59 |
Goal "Forall P (x>>xs)= (P x & Forall P xs)"; |
| 4098 | 60 |
by (simp_tac (simpset() addsimps [Forall_def, sforall_def, |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
61 |
Consq_def,flift2_def]) 1); |
| 3071 | 62 |
qed"Forall_cons"; |
63 |
||
64 |
(* ---------------------------------------------------------------- *) |
|
65 |
(* Conc *) |
|
66 |
(* ---------------------------------------------------------------- *) |
|
67 |
||
68 |
||
| 5068 | 69 |
Goal "(x>>xs) @@ y = x>>(xs @@y)"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
70 |
by (simp_tac (simpset() addsimps [Consq_def]) 1); |
| 3071 | 71 |
qed"Conc_cons"; |
72 |
||
73 |
(* ---------------------------------------------------------------- *) |
|
74 |
(* Takewhile *) |
|
75 |
(* ---------------------------------------------------------------- *) |
|
76 |
||
| 10835 | 77 |
Goal "Takewhile P$UU =UU"; |
| 4098 | 78 |
by (simp_tac (simpset() addsimps [Takewhile_def]) 1); |
| 3071 | 79 |
qed"Takewhile_UU"; |
80 |
||
| 10835 | 81 |
Goal "Takewhile P$nil =nil"; |
| 4098 | 82 |
by (simp_tac (simpset() addsimps [Takewhile_def]) 1); |
| 3071 | 83 |
qed"Takewhile_nil"; |
84 |
||
| 10835 | 85 |
Goal "Takewhile P$(x>>xs)= (if P x then x>>(Takewhile P$xs) else nil)"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
86 |
by (simp_tac (simpset() addsimps [Takewhile_def, Consq_def,flift2_def,If_and_if]) 1); |
| 3071 | 87 |
qed"Takewhile_cons"; |
88 |
||
89 |
(* ---------------------------------------------------------------- *) |
|
90 |
(* Dropwhile *) |
|
91 |
(* ---------------------------------------------------------------- *) |
|
92 |
||
| 10835 | 93 |
Goal "Dropwhile P$UU =UU"; |
| 4098 | 94 |
by (simp_tac (simpset() addsimps [Dropwhile_def]) 1); |
| 3071 | 95 |
qed"Dropwhile_UU"; |
96 |
||
| 10835 | 97 |
Goal "Dropwhile P$nil =nil"; |
| 4098 | 98 |
by (simp_tac (simpset() addsimps [Dropwhile_def]) 1); |
| 3071 | 99 |
qed"Dropwhile_nil"; |
100 |
||
| 10835 | 101 |
Goal "Dropwhile P$(x>>xs)= (if P x then Dropwhile P$xs else x>>xs)"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
102 |
by (simp_tac (simpset() addsimps [Dropwhile_def, Consq_def,flift2_def,If_and_if]) 1); |
| 3071 | 103 |
qed"Dropwhile_cons"; |
104 |
||
105 |
(* ---------------------------------------------------------------- *) |
|
106 |
(* Last *) |
|
107 |
(* ---------------------------------------------------------------- *) |
|
108 |
||
109 |
||
| 10835 | 110 |
Goal "Last$UU =UU"; |
| 4098 | 111 |
by (simp_tac (simpset() addsimps [Last_def]) 1); |
| 3071 | 112 |
qed"Last_UU"; |
113 |
||
| 10835 | 114 |
Goal "Last$nil =UU"; |
| 4098 | 115 |
by (simp_tac (simpset() addsimps [Last_def]) 1); |
| 3071 | 116 |
qed"Last_nil"; |
117 |
||
| 10835 | 118 |
Goal "Last$(x>>xs)= (if xs=nil then Def x else Last$xs)"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
119 |
by (simp_tac (simpset() addsimps [Last_def, Consq_def]) 1); |
| 4042 | 120 |
by (res_inst_tac [("x","xs")] seq.casedist 1);
|
| 4833 | 121 |
by (Asm_simp_tac 1); |
| 3071 | 122 |
by (REPEAT (Asm_simp_tac 1)); |
123 |
qed"Last_cons"; |
|
124 |
||
125 |
||
126 |
(* ---------------------------------------------------------------- *) |
|
127 |
(* Flat *) |
|
128 |
(* ---------------------------------------------------------------- *) |
|
129 |
||
| 10835 | 130 |
Goal "Flat$UU =UU"; |
| 4098 | 131 |
by (simp_tac (simpset() addsimps [Flat_def]) 1); |
| 3071 | 132 |
qed"Flat_UU"; |
133 |
||
| 10835 | 134 |
Goal "Flat$nil =nil"; |
| 4098 | 135 |
by (simp_tac (simpset() addsimps [Flat_def]) 1); |
| 3071 | 136 |
qed"Flat_nil"; |
137 |
||
| 10835 | 138 |
Goal "Flat$(x##xs)= x @@ (Flat$xs)"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
139 |
by (simp_tac (simpset() addsimps [Flat_def, Consq_def]) 1); |
| 3071 | 140 |
qed"Flat_cons"; |
141 |
||
142 |
||
143 |
(* ---------------------------------------------------------------- *) |
|
144 |
(* Zip *) |
|
145 |
(* ---------------------------------------------------------------- *) |
|
146 |
||
| 5068 | 147 |
Goal "Zip = (LAM t1 t2. case t1 of \ |
| 3071 | 148 |
\ nil => nil \ |
149 |
\ | x##xs => (case t2 of \ |
|
150 |
\ nil => UU \ |
|
151 |
\ | y##ys => (case x of \ |
|
| 12028 | 152 |
\ UU => UU \ |
| 3071 | 153 |
\ | Def a => (case y of \ |
| 12028 | 154 |
\ UU => UU \ |
| 10835 | 155 |
\ | Def b => Def (a,b)##(Zip$xs$ys)))))"; |
| 3071 | 156 |
by (rtac trans 1); |
| 3457 | 157 |
by (rtac fix_eq2 1); |
158 |
by (rtac Zip_def 1); |
|
159 |
by (rtac beta_cfun 1); |
|
| 3071 | 160 |
by (Simp_tac 1); |
161 |
qed"Zip_unfold"; |
|
162 |
||
| 10835 | 163 |
Goal "Zip$UU$y =UU"; |
| 3071 | 164 |
by (stac Zip_unfold 1); |
165 |
by (Simp_tac 1); |
|
166 |
qed"Zip_UU1"; |
|
167 |
||
| 10835 | 168 |
Goal "x~=nil ==> Zip$x$UU =UU"; |
| 3071 | 169 |
by (stac Zip_unfold 1); |
170 |
by (Simp_tac 1); |
|
| 4042 | 171 |
by (res_inst_tac [("x","x")] seq.casedist 1);
|
| 3071 | 172 |
by (REPEAT (Asm_full_simp_tac 1)); |
173 |
qed"Zip_UU2"; |
|
174 |
||
| 10835 | 175 |
Goal "Zip$nil$y =nil"; |
| 3071 | 176 |
by (stac Zip_unfold 1); |
177 |
by (Simp_tac 1); |
|
178 |
qed"Zip_nil"; |
|
179 |
||
| 10835 | 180 |
Goal "Zip$(x>>xs)$nil= UU"; |
| 3071 | 181 |
by (stac Zip_unfold 1); |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
182 |
by (simp_tac (simpset() addsimps [Consq_def]) 1); |
| 3071 | 183 |
qed"Zip_cons_nil"; |
184 |
||
| 10835 | 185 |
Goal "Zip$(x>>xs)$(y>>ys)= (x,y) >> Zip$xs$ys"; |
| 3457 | 186 |
by (rtac trans 1); |
| 3071 | 187 |
by (stac Zip_unfold 1); |
188 |
by (Simp_tac 1); |
|
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
189 |
by (simp_tac (simpset() addsimps [Consq_def]) 1); |
| 3071 | 190 |
qed"Zip_cons"; |
191 |
||
192 |
||
193 |
Delsimps [sfilter_UU,sfilter_nil,sfilter_cons, |
|
194 |
smap_UU,smap_nil,smap_cons, |
|
195 |
sforall2_UU,sforall2_nil,sforall2_cons, |
|
196 |
slast_UU,slast_nil,slast_cons, |
|
197 |
stakewhile_UU, stakewhile_nil, stakewhile_cons, |
|
198 |
sdropwhile_UU, sdropwhile_nil, sdropwhile_cons, |
|
199 |
sflat_UU,sflat_nil,sflat_cons, |
|
200 |
szip_UU1,szip_UU2,szip_nil,szip_cons_nil,szip_cons]; |
|
201 |
||
202 |
||
203 |
Addsimps [Filter_UU,Filter_nil,Filter_cons, |
|
204 |
Map_UU,Map_nil,Map_cons, |
|
205 |
Forall_UU,Forall_nil,Forall_cons, |
|
206 |
Last_UU,Last_nil,Last_cons, |
|
| 3275 | 207 |
Conc_cons, |
| 3071 | 208 |
Takewhile_UU, Takewhile_nil, Takewhile_cons, |
209 |
Dropwhile_UU, Dropwhile_nil, Dropwhile_cons, |
|
210 |
Zip_UU1,Zip_UU2,Zip_nil,Zip_cons_nil,Zip_cons]; |
|
211 |
||
212 |
||
213 |
||
214 |
(* ------------------------------------------------------------------------------------- *) |
|
215 |
||
216 |
||
217 |
section "Cons"; |
|
218 |
||
| 5068 | 219 |
Goal "a>>s = (Def a)##s"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
220 |
by (simp_tac (simpset() addsimps [Consq_def]) 1); |
|
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
221 |
qed"Consq_def2"; |
| 3071 | 222 |
|
| 5068 | 223 |
Goal "x = UU | x = nil | (? a s. x = a >> s)"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
224 |
by (simp_tac (simpset() addsimps [Consq_def2]) 1); |
| 3071 | 225 |
by (cut_facts_tac [seq.exhaust] 1); |
226 |
by (fast_tac (HOL_cs addDs [not_Undef_is_Def RS iffD1]) 1); |
|
227 |
qed"Seq_exhaust"; |
|
228 |
||
229 |
||
| 5068 | 230 |
Goal "!!P. [| x = UU ==> P; x = nil ==> P; !!a s. x = a >> s ==> P |] ==> P"; |
| 3071 | 231 |
by (cut_inst_tac [("x","x")] Seq_exhaust 1);
|
| 3457 | 232 |
by (etac disjE 1); |
| 3071 | 233 |
by (Asm_full_simp_tac 1); |
| 3457 | 234 |
by (etac disjE 1); |
| 3071 | 235 |
by (Asm_full_simp_tac 1); |
236 |
by (REPEAT (etac exE 1)); |
|
237 |
by (Asm_full_simp_tac 1); |
|
238 |
qed"Seq_cases"; |
|
239 |
||
240 |
fun Seq_case_tac s i = res_inst_tac [("x",s)] Seq_cases i
|
|
241 |
THEN hyp_subst_tac i THEN hyp_subst_tac (i+1) THEN hyp_subst_tac (i+2); |
|
242 |
||
243 |
(* on a>>s only simp_tac, as full_simp_tac is uncomplete and often causes errors *) |
|
244 |
fun Seq_case_simp_tac s i = Seq_case_tac s i THEN Asm_simp_tac (i+2) |
|
245 |
THEN Asm_full_simp_tac (i+1) |
|
246 |
THEN Asm_full_simp_tac i; |
|
247 |
||
| 5068 | 248 |
Goal "a>>s ~= UU"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
249 |
by (stac Consq_def2 1); |
| 3071 | 250 |
by (resolve_tac seq.con_rews 1); |
| 3457 | 251 |
by (rtac Def_not_UU 1); |
| 3071 | 252 |
qed"Cons_not_UU"; |
253 |
||
| 3275 | 254 |
|
| 5068 | 255 |
Goal "~(a>>x) << UU"; |
| 3071 | 256 |
by (rtac notI 1); |
257 |
by (dtac antisym_less 1); |
|
258 |
by (Simp_tac 1); |
|
| 4098 | 259 |
by (asm_full_simp_tac (simpset() addsimps [Cons_not_UU]) 1); |
| 3071 | 260 |
qed"Cons_not_less_UU"; |
261 |
||
| 5068 | 262 |
Goal "~a>>s << nil"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
263 |
by (stac Consq_def2 1); |
| 3071 | 264 |
by (resolve_tac seq.rews 1); |
| 3457 | 265 |
by (rtac Def_not_UU 1); |
| 3071 | 266 |
qed"Cons_not_less_nil"; |
267 |
||
| 5068 | 268 |
Goal "a>>s ~= nil"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
269 |
by (stac Consq_def2 1); |
| 3071 | 270 |
by (resolve_tac seq.rews 1); |
271 |
qed"Cons_not_nil"; |
|
272 |
||
| 5068 | 273 |
Goal "nil ~= a>>s"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
274 |
by (simp_tac (simpset() addsimps [Consq_def2]) 1); |
| 3275 | 275 |
qed"Cons_not_nil2"; |
276 |
||
| 5068 | 277 |
Goal "(a>>s = b>>t) = (a = b & s = t)"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
278 |
by (simp_tac (HOL_ss addsimps [Consq_def2]) 1); |
| 3071 | 279 |
by (stac (hd lift.inject RS sym) 1); |
280 |
back(); back(); |
|
281 |
by (rtac scons_inject_eq 1); |
|
282 |
by (REPEAT(rtac Def_not_UU 1)); |
|
283 |
qed"Cons_inject_eq"; |
|
284 |
||
| 5068 | 285 |
Goal "(a>>s<<b>>t) = (a = b & s<<t)"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
286 |
by (simp_tac (simpset() addsimps [Consq_def2]) 1); |
| 3071 | 287 |
by (stac (Def_inject_less_eq RS sym) 1); |
288 |
back(); |
|
289 |
by (rtac iffI 1); |
|
290 |
(* 1 *) |
|
291 |
by (etac (hd seq.inverts) 1); |
|
292 |
by (REPEAT(rtac Def_not_UU 1)); |
|
293 |
(* 2 *) |
|
294 |
by (Asm_full_simp_tac 1); |
|
295 |
by (etac conjE 1); |
|
296 |
by (etac monofun_cfun_arg 1); |
|
297 |
qed"Cons_inject_less_eq"; |
|
298 |
||
| 10835 | 299 |
Goal "seq_take (Suc n)$(a>>x) = a>> (seq_take n$x)"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
300 |
by (simp_tac (simpset() addsimps [Consq_def]) 1); |
| 3071 | 301 |
qed"seq_take_Cons"; |
302 |
||
| 3275 | 303 |
Addsimps [Cons_not_nil2,Cons_inject_eq,Cons_inject_less_eq,seq_take_Cons, |
| 3071 | 304 |
Cons_not_UU,Cons_not_less_UU,Cons_not_less_nil,Cons_not_nil]; |
305 |
||
| 3275 | 306 |
(* Instead of adding UU_neq_Cons every equation UU~=x could be changed to x~=UU *) |
| 5068 | 307 |
Goal "UU ~= x>>xs"; |
| 3275 | 308 |
by (res_inst_tac [("s1","UU"),("t1","x>>xs")] (sym RS rev_contrapos) 1);
|
309 |
by (REPEAT (Simp_tac 1)); |
|
310 |
qed"UU_neq_Cons"; |
|
311 |
||
312 |
Addsimps [UU_neq_Cons]; |
|
313 |
||
| 3071 | 314 |
|
315 |
(* ----------------------------------------------------------------------------------- *) |
|
316 |
||
317 |
section "induction"; |
|
318 |
||
| 5068 | 319 |
Goal "!! P. [| adm P; P UU; P nil; !! a s. P s ==> P (a>>s)|] ==> P x"; |
| 3457 | 320 |
by (etac seq.ind 1); |
| 3071 | 321 |
by (REPEAT (atac 1)); |
322 |
by (def_tac 1); |
|
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
323 |
by (asm_full_simp_tac (simpset() addsimps [Consq_def]) 1); |
| 3071 | 324 |
qed"Seq_induct"; |
325 |
||
| 5068 | 326 |
Goal "!! P.[|P UU;P nil; !! a s. P s ==> P(a>>s) |] \ |
| 3071 | 327 |
\ ==> seq_finite x --> P x"; |
| 3457 | 328 |
by (etac seq_finite_ind 1); |
| 3071 | 329 |
by (REPEAT (atac 1)); |
330 |
by (def_tac 1); |
|
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
331 |
by (asm_full_simp_tac (simpset() addsimps [Consq_def]) 1); |
| 3071 | 332 |
qed"Seq_FinitePartial_ind"; |
333 |
||
| 5068 | 334 |
Goal "!! P.[| Finite x; P nil; !! a s. [| Finite s; P s|] ==> P (a>>s) |] ==> P x"; |
| 3457 | 335 |
by (etac sfinite.induct 1); |
336 |
by (assume_tac 1); |
|
| 3071 | 337 |
by (def_tac 1); |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
338 |
by (asm_full_simp_tac (simpset() addsimps [Consq_def]) 1); |
| 3071 | 339 |
qed"Seq_Finite_ind"; |
340 |
||
341 |
||
342 |
(* rws are definitions to be unfolded for admissibility check *) |
|
343 |
fun Seq_induct_tac s rws i = res_inst_tac [("x",s)] Seq_induct i
|
|
344 |
THEN (REPEAT_DETERM (CHANGED (Asm_simp_tac (i+1)))) |
|
| 4098 | 345 |
THEN simp_tac (simpset() addsimps rws) i; |
| 3071 | 346 |
|
347 |
fun Seq_Finite_induct_tac i = etac Seq_Finite_ind i |
|
348 |
THEN (REPEAT_DETERM (CHANGED (Asm_simp_tac i))); |
|
349 |
||
350 |
fun pair_tac s = res_inst_tac [("p",s)] PairE
|
|
351 |
THEN' hyp_subst_tac THEN' Asm_full_simp_tac; |
|
352 |
||
353 |
(* induction on a sequence of pairs with pairsplitting and simplification *) |
|
354 |
fun pair_induct_tac s rws i = |
|
355 |
res_inst_tac [("x",s)] Seq_induct i
|
|
356 |
THEN pair_tac "a" (i+3) |
|
357 |
THEN (REPEAT_DETERM (CHANGED (Simp_tac (i+1)))) |
|
| 4098 | 358 |
THEN simp_tac (simpset() addsimps rws) i; |
| 3071 | 359 |
|
360 |
||
361 |
||
362 |
(* ------------------------------------------------------------------------------------ *) |
|
363 |
||
364 |
section "HD,TL"; |
|
365 |
||
| 10835 | 366 |
Goal "HD$(x>>y) = Def x"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
367 |
by (simp_tac (simpset() addsimps [Consq_def]) 1); |
| 3071 | 368 |
qed"HD_Cons"; |
369 |
||
| 10835 | 370 |
Goal "TL$(x>>y) = y"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
371 |
by (simp_tac (simpset() addsimps [Consq_def]) 1); |
| 3071 | 372 |
qed"TL_Cons"; |
373 |
||
374 |
Addsimps [HD_Cons,TL_Cons]; |
|
375 |
||
376 |
(* ------------------------------------------------------------------------------------ *) |
|
377 |
||
378 |
section "Finite, Partial, Infinite"; |
|
379 |
||
| 5068 | 380 |
Goal "Finite (a>>xs) = Finite xs"; |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
381 |
by (simp_tac (simpset() addsimps [Consq_def2,Finite_cons]) 1); |
| 3071 | 382 |
qed"Finite_Cons"; |
383 |
||
384 |
Addsimps [Finite_Cons]; |
|
| 6161 | 385 |
Goal "Finite (x::'a Seq) ==> Finite y --> Finite (x@@y)"; |
| 3275 | 386 |
by (Seq_Finite_induct_tac 1); |
387 |
qed"FiniteConc_1"; |
|
388 |
||
| 6161 | 389 |
Goal "Finite (z::'a Seq) ==> !x y. z= x@@y --> (Finite x & Finite y)"; |
| 3275 | 390 |
by (Seq_Finite_induct_tac 1); |
391 |
(* nil*) |
|
392 |
by (strip_tac 1); |
|
393 |
by (Seq_case_simp_tac "x" 1); |
|
394 |
by (Asm_full_simp_tac 1); |
|
395 |
(* cons *) |
|
396 |
by (strip_tac 1); |
|
397 |
by (Seq_case_simp_tac "x" 1); |
|
398 |
by (Seq_case_simp_tac "y" 1); |
|
| 4098 | 399 |
by (SELECT_GOAL (auto_tac (claset(),simpset()))1); |
| 3275 | 400 |
by (eres_inst_tac [("x","sa")] allE 1);
|
401 |
by (eres_inst_tac [("x","y")] allE 1);
|
|
402 |
by (Asm_full_simp_tac 1); |
|
403 |
qed"FiniteConc_2"; |
|
404 |
||
| 5068 | 405 |
Goal "Finite(x@@y) = (Finite (x::'a Seq) & Finite y)"; |
| 3275 | 406 |
by (rtac iffI 1); |
| 3457 | 407 |
by (etac (FiniteConc_2 RS spec RS spec RS mp) 1); |
408 |
by (rtac refl 1); |
|
409 |
by (rtac (FiniteConc_1 RS mp) 1); |
|
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
410 |
by Auto_tac; |
| 3275 | 411 |
qed"FiniteConc"; |
412 |
||
413 |
Addsimps [FiniteConc]; |
|
414 |
||
415 |
||
| 10835 | 416 |
Goal "Finite s ==> Finite (Map f$s)"; |
| 3275 | 417 |
by (Seq_Finite_induct_tac 1); |
418 |
qed"FiniteMap1"; |
|
419 |
||
| 10835 | 420 |
Goal "Finite s ==> ! t. (s = Map f$t) --> Finite t"; |
| 3275 | 421 |
by (Seq_Finite_induct_tac 1); |
422 |
by (strip_tac 1); |
|
423 |
by (Seq_case_simp_tac "t" 1); |
|
424 |
by (Asm_full_simp_tac 1); |
|
425 |
(* main case *) |
|
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
426 |
by Auto_tac; |
| 3275 | 427 |
by (Seq_case_simp_tac "t" 1); |
428 |
by (Asm_full_simp_tac 1); |
|
429 |
qed"FiniteMap2"; |
|
430 |
||
| 10835 | 431 |
Goal "Finite (Map f$s) = Finite s"; |
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
432 |
by Auto_tac; |
| 3457 | 433 |
by (etac (FiniteMap2 RS spec RS mp) 1); |
434 |
by (rtac refl 1); |
|
435 |
by (etac FiniteMap1 1); |
|
| 3275 | 436 |
qed"Map2Finite"; |
437 |
||
|
3433
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3361
diff
changeset
|
438 |
|
| 10835 | 439 |
Goal "Finite s ==> Finite (Filter P$s)"; |
|
3433
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3361
diff
changeset
|
440 |
by (Seq_Finite_induct_tac 1); |
|
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3361
diff
changeset
|
441 |
qed"FiniteFilter"; |
|
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3361
diff
changeset
|
442 |
|
|
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3361
diff
changeset
|
443 |
|
| 3361 | 444 |
(* ----------------------------------------------------------------------------------- *) |
445 |
||
446 |
||
447 |
section "admissibility"; |
|
448 |
||
449 |
(* Finite x is proven to be adm: Finite_flat shows that there are only chains of length one. |
|
| 3461 | 450 |
Then the assumption that an _infinite_ chain exists (from admI2) is set to a contradiction |
| 3361 | 451 |
to Finite_flat *) |
452 |
||
| 5068 | 453 |
Goal "!! (x:: 'a Seq). Finite x ==> !y. Finite (y:: 'a Seq) & x<<y --> x=y"; |
| 3361 | 454 |
by (Seq_Finite_induct_tac 1); |
455 |
by (strip_tac 1); |
|
| 3457 | 456 |
by (etac conjE 1); |
457 |
by (etac nil_less_is_nil 1); |
|
| 3361 | 458 |
(* main case *) |
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
459 |
by Auto_tac; |
| 3361 | 460 |
by (Seq_case_simp_tac "y" 1); |
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
461 |
by Auto_tac; |
| 3361 | 462 |
qed_spec_mp"Finite_flat"; |
463 |
||
464 |
||
| 5068 | 465 |
Goal "adm(%(x:: 'a Seq).Finite x)"; |
| 3461 | 466 |
by (rtac admI2 1); |
| 3361 | 467 |
by (eres_inst_tac [("x","0")] allE 1);
|
468 |
back(); |
|
| 3457 | 469 |
by (etac exE 1); |
| 3361 | 470 |
by (REPEAT (etac conjE 1)); |
471 |
by (res_inst_tac [("x","0")] allE 1);
|
|
| 3457 | 472 |
by (assume_tac 1); |
| 3361 | 473 |
by (eres_inst_tac [("x","j")] allE 1);
|
474 |
by (cut_inst_tac [("x","Y 0"),("y","Y j")] Finite_flat 1);
|
|
475 |
(* Generates a contradiction in subgoal 3 *) |
|
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
476 |
by Auto_tac; |
| 3361 | 477 |
qed"adm_Finite"; |
478 |
||
479 |
Addsimps [adm_Finite]; |
|
480 |
||
| 3071 | 481 |
|
482 |
(* ------------------------------------------------------------------------------------ *) |
|
483 |
||
484 |
section "Conc"; |
|
485 |
||
| 5068 | 486 |
Goal "!! x::'a Seq. Finite x ==> ((x @@ y) = (x @@ z)) = (y = z)"; |
| 3071 | 487 |
by (Seq_Finite_induct_tac 1); |
488 |
qed"Conc_cong"; |
|
489 |
||
| 5068 | 490 |
Goal "(x @@ y) @@ z = (x::'a Seq) @@ y @@ z"; |
| 3275 | 491 |
by (Seq_induct_tac "x" [] 1); |
492 |
qed"Conc_assoc"; |
|
493 |
||
| 5068 | 494 |
Goal "s@@ nil = s"; |
| 3275 | 495 |
by (res_inst_tac[("x","s")] seq.ind 1);
|
496 |
by (Simp_tac 1); |
|
497 |
by (Simp_tac 1); |
|
498 |
by (Simp_tac 1); |
|
499 |
by (Asm_full_simp_tac 1); |
|
500 |
qed"nilConc"; |
|
501 |
||
502 |
Addsimps [nilConc]; |
|
503 |
||
| 5976 | 504 |
(* should be same as nil_is_Conc2 when all nils are turned to right side !! *) |
| 5068 | 505 |
Goal "(nil = x @@ y) = ((x::'a Seq)= nil & y = nil)"; |
| 3361 | 506 |
by (Seq_case_simp_tac "x" 1); |
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
507 |
by Auto_tac; |
| 3361 | 508 |
qed"nil_is_Conc"; |
509 |
||
| 5068 | 510 |
Goal "(x @@ y = nil) = ((x::'a Seq)= nil & y = nil)"; |
| 3361 | 511 |
by (Seq_case_simp_tac "x" 1); |
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
512 |
by Auto_tac; |
| 3361 | 513 |
qed"nil_is_Conc2"; |
514 |
||
| 3275 | 515 |
|
| 3071 | 516 |
(* ------------------------------------------------------------------------------------ *) |
517 |
||
518 |
section "Last"; |
|
519 |
||
| 10835 | 520 |
Goal "Finite s ==> s~=nil --> Last$s~=UU"; |
| 3071 | 521 |
by (Seq_Finite_induct_tac 1); |
522 |
qed"Finite_Last1"; |
|
523 |
||
| 10835 | 524 |
Goal "Finite s ==> Last$s=UU --> s=nil"; |
| 3071 | 525 |
by (Seq_Finite_induct_tac 1); |
526 |
by (fast_tac HOL_cs 1); |
|
527 |
qed"Finite_Last2"; |
|
528 |
||
529 |
||
530 |
(* ------------------------------------------------------------------------------------ *) |
|
531 |
||
532 |
||
533 |
section "Filter, Conc"; |
|
534 |
||
535 |
||
| 10835 | 536 |
Goal "Filter P$(Filter Q$s) = Filter (%x. P x & Q x)$s"; |
| 3071 | 537 |
by (Seq_induct_tac "s" [Filter_def] 1); |
538 |
qed"FilterPQ"; |
|
539 |
||
| 10835 | 540 |
Goal "Filter P$(x @@ y) = (Filter P$x @@ Filter P$y)"; |
| 4098 | 541 |
by (simp_tac (simpset() addsimps [Filter_def,sfiltersconc]) 1); |
| 3071 | 542 |
qed"FilterConc"; |
543 |
||
544 |
(* ------------------------------------------------------------------------------------ *) |
|
545 |
||
546 |
section "Map"; |
|
547 |
||
| 10835 | 548 |
Goal "Map f$(Map g$s) = Map (f o g)$s"; |
| 3071 | 549 |
by (Seq_induct_tac "s" [] 1); |
550 |
qed"MapMap"; |
|
551 |
||
| 10835 | 552 |
Goal "Map f$(x@@y) = (Map f$x) @@ (Map f$y)"; |
| 3071 | 553 |
by (Seq_induct_tac "x" [] 1); |
554 |
qed"MapConc"; |
|
555 |
||
| 10835 | 556 |
Goal "Filter P$(Map f$x) = Map f$(Filter (P o f)$x)"; |
| 3071 | 557 |
by (Seq_induct_tac "x" [] 1); |
558 |
qed"MapFilter"; |
|
559 |
||
| 10835 | 560 |
Goal "nil = (Map f$s) --> s= nil"; |
| 3275 | 561 |
by (Seq_case_simp_tac "s" 1); |
562 |
qed"nilMap"; |
|
563 |
||
| 3361 | 564 |
|
| 10835 | 565 |
Goal "Forall P (Map f$s) = Forall (P o f) s"; |
| 3275 | 566 |
by (Seq_induct_tac "s" [Forall_def,sforall_def] 1); |
| 3361 | 567 |
qed"ForallMap"; |
| 3275 | 568 |
|
569 |
||
570 |
||
| 3071 | 571 |
|
572 |
(* ------------------------------------------------------------------------------------ *) |
|
573 |
||
| 3275 | 574 |
section "Forall"; |
| 3071 | 575 |
|
576 |
||
| 5068 | 577 |
Goal "Forall P ys & (! x. P x --> Q x) \ |
| 3071 | 578 |
\ --> Forall Q ys"; |
579 |
by (Seq_induct_tac "ys" [Forall_def,sforall_def] 1); |
|
580 |
qed"ForallPForallQ1"; |
|
581 |
||
582 |
bind_thm ("ForallPForallQ",impI RSN (2,allI RSN (2,conjI RS (ForallPForallQ1 RS mp))));
|
|
583 |
||
| 5068 | 584 |
Goal "(Forall P x & Forall P y) --> Forall P (x @@ y)"; |
| 3071 | 585 |
by (Seq_induct_tac "x" [Forall_def,sforall_def] 1); |
586 |
qed"Forall_Conc_impl"; |
|
587 |
||
| 6161 | 588 |
Goal "Finite x ==> Forall P (x @@ y) = (Forall P x & Forall P y)"; |
| 3071 | 589 |
by (Seq_Finite_induct_tac 1); |
590 |
qed"Forall_Conc"; |
|
591 |
||
| 3275 | 592 |
Addsimps [Forall_Conc]; |
593 |
||
| 10835 | 594 |
Goal "Forall P s --> Forall P (TL$s)"; |
| 3275 | 595 |
by (Seq_induct_tac "s" [Forall_def,sforall_def] 1); |
596 |
qed"ForallTL1"; |
|
597 |
||
598 |
bind_thm ("ForallTL",ForallTL1 RS mp);
|
|
599 |
||
| 10835 | 600 |
Goal "Forall P s --> Forall P (Dropwhile Q$s)"; |
| 3275 | 601 |
by (Seq_induct_tac "s" [Forall_def,sforall_def] 1); |
602 |
qed"ForallDropwhile1"; |
|
603 |
||
604 |
bind_thm ("ForallDropwhile",ForallDropwhile1 RS mp);
|
|
605 |
||
606 |
||
607 |
(* only admissible in t, not if done in s *) |
|
608 |
||
| 5068 | 609 |
Goal "! s. Forall P s --> t<<s --> Forall P t"; |
| 3275 | 610 |
by (Seq_induct_tac "t" [Forall_def,sforall_def] 1); |
611 |
by (strip_tac 1); |
|
612 |
by (Seq_case_simp_tac "sa" 1); |
|
613 |
by (Asm_full_simp_tac 1); |
|
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
614 |
by Auto_tac; |
| 3275 | 615 |
qed"Forall_prefix"; |
| 4681 | 616 |
|
| 3275 | 617 |
bind_thm ("Forall_prefixclosed",Forall_prefix RS spec RS mp RS mp);
|
618 |
||
619 |
||
| 6161 | 620 |
Goal "[| Finite h; Forall P s; s= h @@ t |] ==> Forall P t"; |
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
621 |
by Auto_tac; |
| 3275 | 622 |
qed"Forall_postfixclosed"; |
623 |
||
624 |
||
| 10835 | 625 |
Goal "((! x. P x --> (Q x = R x)) & Forall P tr) --> Filter Q$tr = Filter R$tr"; |
| 3275 | 626 |
by (Seq_induct_tac "tr" [Forall_def,sforall_def] 1); |
627 |
qed"ForallPFilterQR1"; |
|
628 |
||
629 |
bind_thm("ForallPFilterQR",allI RS (conjI RS (ForallPFilterQR1 RS mp)));
|
|
630 |
||
| 3071 | 631 |
|
632 |
(* ------------------------------------------------------------------------------------- *) |
|
633 |
||
634 |
section "Forall, Filter"; |
|
635 |
||
636 |
||
| 10835 | 637 |
Goal "Forall P (Filter P$x)"; |
| 4098 | 638 |
by (simp_tac (simpset() addsimps [Filter_def,Forall_def,forallPsfilterP]) 1); |
| 3071 | 639 |
qed"ForallPFilterP"; |
640 |
||
| 3275 | 641 |
(* holds also in other direction, then equal to forallPfilterP *) |
| 10835 | 642 |
Goal "Forall P x --> Filter P$x = x"; |
| 3071 | 643 |
by (Seq_induct_tac "x" [Forall_def,sforall_def,Filter_def] 1); |
644 |
qed"ForallPFilterPid1"; |
|
645 |
||
| 4034 | 646 |
bind_thm("ForallPFilterPid",ForallPFilterPid1 RS mp);
|
| 3071 | 647 |
|
648 |
||
| 3275 | 649 |
(* holds also in other direction *) |
| 5068 | 650 |
Goal "!! ys . Finite ys ==> \ |
| 10835 | 651 |
\ Forall (%x. ~P x) ys --> Filter P$ys = nil "; |
| 3275 | 652 |
by (Seq_Finite_induct_tac 1); |
| 3071 | 653 |
qed"ForallnPFilterPnil1"; |
654 |
||
| 3275 | 655 |
bind_thm ("ForallnPFilterPnil",ForallnPFilterPnil1 RS mp);
|
| 3071 | 656 |
|
657 |
||
| 3275 | 658 |
(* holds also in other direction *) |
| 6161 | 659 |
Goal "~Finite ys & Forall (%x. ~P x) ys \ |
| 10835 | 660 |
\ --> Filter P$ys = UU "; |
| 3361 | 661 |
by (Seq_induct_tac "ys" [Forall_def,sforall_def] 1); |
| 3071 | 662 |
qed"ForallnPFilterPUU1"; |
663 |
||
| 3275 | 664 |
bind_thm ("ForallnPFilterPUU",conjI RS (ForallnPFilterPUU1 RS mp));
|
665 |
||
666 |
||
667 |
(* inverse of ForallnPFilterPnil *) |
|
668 |
||
| 10835 | 669 |
Goal "!! ys . Filter P$ys = nil --> \ |
| 3275 | 670 |
\ (Forall (%x. ~P x) ys & Finite ys)"; |
671 |
by (res_inst_tac[("x","ys")] Seq_induct 1);
|
|
672 |
(* adm *) |
|
| 3361 | 673 |
(* FIX: not admissible, search other proof!! *) |
| 3457 | 674 |
by (rtac adm_all 1); |
| 3275 | 675 |
(* base cases *) |
676 |
by (Simp_tac 1); |
|
677 |
by (Simp_tac 1); |
|
678 |
(* main case *) |
|
| 4833 | 679 |
by (Asm_full_simp_tac 1); |
| 3275 | 680 |
qed"FilternPnilForallP1"; |
681 |
||
682 |
bind_thm ("FilternPnilForallP",FilternPnilForallP1 RS mp);
|
|
683 |
||
| 3361 | 684 |
(* inverse of ForallnPFilterPUU. proved by 2 lemmas because of adm problems *) |
685 |
||
| 10835 | 686 |
Goal "Finite ys ==> Filter P$ys ~= UU"; |
| 3361 | 687 |
by (Seq_Finite_induct_tac 1); |
688 |
qed"FilterUU_nFinite_lemma1"; |
|
| 3275 | 689 |
|
| 10835 | 690 |
Goal "~ Forall (%x. ~P x) ys --> Filter P$ys ~= UU"; |
| 3361 | 691 |
by (Seq_induct_tac "ys" [Forall_def,sforall_def] 1); |
692 |
qed"FilterUU_nFinite_lemma2"; |
|
693 |
||
| 10835 | 694 |
Goal "Filter P$ys = UU ==> \ |
| 3275 | 695 |
\ (Forall (%x. ~P x) ys & ~Finite ys)"; |
| 3361 | 696 |
by (rtac conjI 1); |
697 |
by (cut_inst_tac [] (FilterUU_nFinite_lemma2 RS mp COMP rev_contrapos) 1); |
|
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
698 |
by Auto_tac; |
| 4098 | 699 |
by (blast_tac (claset() addSDs [FilterUU_nFinite_lemma1]) 1); |
| 3361 | 700 |
qed"FilternPUUForallP"; |
| 3071 | 701 |
|
702 |
||
| 5068 | 703 |
Goal "!! Q P.[| Forall Q ys; Finite ys; !!x. Q x ==> ~P x|] \ |
| 10835 | 704 |
\ ==> Filter P$ys = nil"; |
| 3457 | 705 |
by (etac ForallnPFilterPnil 1); |
706 |
by (etac ForallPForallQ 1); |
|
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
707 |
by Auto_tac; |
| 3071 | 708 |
qed"ForallQFilterPnil"; |
709 |
||
| 5068 | 710 |
Goal "!! Q P. [| ~Finite ys; Forall Q ys; !!x. Q x ==> ~P x|] \ |
| 10835 | 711 |
\ ==> Filter P$ys = UU "; |
| 3457 | 712 |
by (etac ForallnPFilterPUU 1); |
713 |
by (etac ForallPForallQ 1); |
|
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
714 |
by Auto_tac; |
| 3071 | 715 |
qed"ForallQFilterPUU"; |
716 |
||
717 |
||
718 |
||
719 |
(* ------------------------------------------------------------------------------------- *) |
|
720 |
||
721 |
section "Takewhile, Forall, Filter"; |
|
722 |
||
723 |
||
| 10835 | 724 |
Goal "Forall P (Takewhile P$x)"; |
| 4098 | 725 |
by (simp_tac (simpset() addsimps [Forall_def,Takewhile_def,sforallPstakewhileP]) 1); |
| 3071 | 726 |
qed"ForallPTakewhileP"; |
727 |
||
728 |
||
| 10835 | 729 |
Goal"!! P. [| !!x. Q x==> P x |] ==> Forall P (Takewhile Q$x)"; |
| 3457 | 730 |
by (rtac ForallPForallQ 1); |
731 |
by (rtac ForallPTakewhileP 1); |
|
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
732 |
by Auto_tac; |
| 3071 | 733 |
qed"ForallPTakewhileQ"; |
734 |
||
735 |
||
| 10835 | 736 |
Goal "!! Q P.[| Finite (Takewhile Q$ys); !!x. Q x ==> ~P x |] \ |
737 |
\ ==> Filter P$(Takewhile Q$ys) = nil"; |
|
| 3457 | 738 |
by (etac ForallnPFilterPnil 1); |
739 |
by (rtac ForallPForallQ 1); |
|
740 |
by (rtac ForallPTakewhileP 1); |
|
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
741 |
by Auto_tac; |
| 3071 | 742 |
qed"FilterPTakewhileQnil"; |
743 |
||
| 5068 | 744 |
Goal "!! Q P. [| !!x. Q x ==> P x |] ==> \ |
| 10835 | 745 |
\ Filter P$(Takewhile Q$ys) = (Takewhile Q$ys)"; |
| 3457 | 746 |
by (rtac ForallPFilterPid 1); |
747 |
by (rtac ForallPForallQ 1); |
|
748 |
by (rtac ForallPTakewhileP 1); |
|
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
749 |
by Auto_tac; |
| 3071 | 750 |
qed"FilterPTakewhileQid"; |
751 |
||
752 |
Addsimps [ForallPTakewhileP,ForallPTakewhileQ, |
|
753 |
FilterPTakewhileQnil,FilterPTakewhileQid]; |
|
754 |
||
| 10835 | 755 |
Goal "Takewhile P$(Takewhile P$s) = Takewhile P$s"; |
| 3275 | 756 |
by (Seq_induct_tac "s" [Forall_def,sforall_def] 1); |
757 |
qed"Takewhile_idempotent"; |
|
| 3071 | 758 |
|
| 10835 | 759 |
Goal "Forall P s --> Takewhile (%x. Q x | (~P x))$s = Takewhile Q$s"; |
| 3275 | 760 |
by (Seq_induct_tac "s" [Forall_def,sforall_def] 1); |
761 |
qed"ForallPTakewhileQnP"; |
|
762 |
||
| 10835 | 763 |
Goal "Forall P s --> Dropwhile (%x. Q x | (~P x))$s = Dropwhile Q$s"; |
| 3275 | 764 |
by (Seq_induct_tac "s" [Forall_def,sforall_def] 1); |
765 |
qed"ForallPDropwhileQnP"; |
|
766 |
||
767 |
Addsimps [ForallPTakewhileQnP RS mp, ForallPDropwhileQnP RS mp]; |
|
768 |
||
769 |
||
| 10835 | 770 |
Goal "Forall P s --> Takewhile P$(s @@ t) = s @@ (Takewhile P$t)"; |
| 3275 | 771 |
by (Seq_induct_tac "s" [Forall_def,sforall_def] 1); |
772 |
qed"TakewhileConc1"; |
|
773 |
||
774 |
bind_thm("TakewhileConc",TakewhileConc1 RS mp);
|
|
775 |
||
| 10835 | 776 |
Goal "Finite s ==> Forall P s --> Dropwhile P$(s @@ t) = Dropwhile P$t"; |
| 3275 | 777 |
by (Seq_Finite_induct_tac 1); |
778 |
qed"DropwhileConc1"; |
|
779 |
||
780 |
bind_thm("DropwhileConc",DropwhileConc1 RS mp);
|
|
| 3071 | 781 |
|
782 |
||
783 |
||
784 |
(* ----------------------------------------------------------------------------------- *) |
|
785 |
||
786 |
section "coinductive characterizations of Filter"; |
|
787 |
||
788 |
||
| 10835 | 789 |
Goal "HD$(Filter P$y) = Def x \ |
790 |
\ --> y = ((Takewhile (%x. ~P x)$y) @@ (x >> TL$(Dropwhile (%a.~P a)$y))) \ |
|
791 |
\ & Finite (Takewhile (%x. ~ P x)$y) & P x"; |
|
| 3071 | 792 |
|
793 |
(* FIX: pay attention: is only admissible with chain-finite package to be added to |
|
| 3656 | 794 |
adm test and Finite f x admissibility *) |
| 3071 | 795 |
by (Seq_induct_tac "y" [] 1); |
| 3457 | 796 |
by (rtac adm_all 1); |
| 3071 | 797 |
by (Asm_full_simp_tac 1); |
798 |
by (case_tac "P a" 1); |
|
| 4681 | 799 |
by (Asm_full_simp_tac 1); |
800 |
by (Blast_tac 1); |
|
| 3071 | 801 |
(* ~ P a *) |
802 |
by (Asm_full_simp_tac 1); |
|
803 |
qed"divide_Seq_lemma"; |
|
804 |
||
| 10835 | 805 |
Goal "(x>>xs) << Filter P$y \ |
806 |
\ ==> y = ((Takewhile (%a. ~ P a)$y) @@ (x >> TL$(Dropwhile (%a.~P a)$y))) \ |
|
807 |
\ & Finite (Takewhile (%a. ~ P a)$y) & P x"; |
|
| 3457 | 808 |
by (rtac (divide_Seq_lemma RS mp) 1); |
| 15594 | 809 |
by (dres_inst_tac [("fo","HD"),("x","x>>xs")] monofun_cfun_arg 1);
|
| 3071 | 810 |
by (Asm_full_simp_tac 1); |
811 |
qed"divide_Seq"; |
|
812 |
||
| 3656 | 813 |
|
| 10835 | 814 |
Goal "~Forall P y --> (? x. HD$(Filter (%a. ~P a)$y) = Def x)"; |
| 3656 | 815 |
(* Pay attention: is only admissible with chain-finite package to be added to |
| 3071 | 816 |
adm test *) |
| 3656 | 817 |
by (Seq_induct_tac "y" [Forall_def,sforall_def] 1); |
| 3071 | 818 |
qed"nForall_HDFilter"; |
819 |
||
820 |
||
| 6161 | 821 |
Goal "~Forall P y \ |
| 10835 | 822 |
\ ==> ? x. y= (Takewhile P$y @@ (x >> TL$(Dropwhile P$y))) & \ |
823 |
\ Finite (Takewhile P$y) & (~ P x)"; |
|
| 3457 | 824 |
by (dtac (nForall_HDFilter RS mp) 1); |
| 3071 | 825 |
by (safe_tac set_cs); |
826 |
by (res_inst_tac [("x","x")] exI 1);
|
|
827 |
by (cut_inst_tac [("P1","%x. ~ P x")] (divide_Seq_lemma RS mp) 1);
|
|
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
828 |
by Auto_tac; |
| 3071 | 829 |
qed"divide_Seq2"; |
830 |
||
831 |
||
| 6161 | 832 |
Goal "~Forall P y \ |
| 3071 | 833 |
\ ==> ? x bs rs. y= (bs @@ (x>>rs)) & Finite bs & Forall P bs & (~ P x)"; |
834 |
by (cut_inst_tac [] divide_Seq2 1); |
|
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
835 |
(*Auto_tac no longer proves it*) |
|
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
836 |
by (REPEAT (fast_tac (claset() addss (simpset())) 1)); |
| 3071 | 837 |
qed"divide_Seq3"; |
838 |
||
| 3275 | 839 |
Addsimps [FilterPQ,FilterConc,Conc_cong]; |
| 3071 | 840 |
|
841 |
||
842 |
(* ------------------------------------------------------------------------------------- *) |
|
843 |
||
844 |
||
845 |
section "take_lemma"; |
|
846 |
||
| 10835 | 847 |
Goal "(!n. seq_take n$x = seq_take n$x') = (x = x')"; |
| 3071 | 848 |
by (rtac iffI 1); |
| 4042 | 849 |
by (resolve_tac seq.take_lemmas 1); |
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
850 |
by Auto_tac; |
| 3071 | 851 |
qed"seq_take_lemma"; |
852 |
||
| 5068 | 853 |
Goal |
| 10835 | 854 |
" ! n. ((! k. k < n --> seq_take k$y1 = seq_take k$y2) \ |
855 |
\ --> seq_take n$(x @@ (t>>y1)) = seq_take n$(x @@ (t>>y2)))"; |
|
| 3275 | 856 |
by (Seq_induct_tac "x" [] 1); |
857 |
by (strip_tac 1); |
|
| 8439 | 858 |
by (case_tac "n" 1); |
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
859 |
by Auto_tac; |
| 8439 | 860 |
by (case_tac "n" 1); |
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
861 |
by Auto_tac; |
| 3275 | 862 |
qed"take_reduction1"; |
| 3071 | 863 |
|
864 |
||
| 10835 | 865 |
Goal "!! n.[| x=y; s=t; !! k. k<n ==> seq_take k$y1 = seq_take k$y2|] \ |
866 |
\ ==> seq_take n$(x @@ (s>>y1)) = seq_take n$(y @@ (t>>y2))"; |
|
| 3071 | 867 |
|
| 4098 | 868 |
by (auto_tac (claset() addSIs [take_reduction1 RS spec RS mp],simpset())); |
| 3071 | 869 |
qed"take_reduction"; |
| 3275 | 870 |
|
| 3361 | 871 |
(* ------------------------------------------------------------------ |
872 |
take-lemma and take_reduction for << instead of = |
|
873 |
------------------------------------------------------------------ *) |
|
874 |
||
| 5068 | 875 |
Goal |
| 10835 | 876 |
" ! n. ((! k. k < n --> seq_take k$y1 << seq_take k$y2) \ |
877 |
\ --> seq_take n$(x @@ (t>>y1)) << seq_take n$(x @@ (t>>y2)))"; |
|
| 3361 | 878 |
by (Seq_induct_tac "x" [] 1); |
879 |
by (strip_tac 1); |
|
| 8439 | 880 |
by (case_tac "n" 1); |
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
881 |
by Auto_tac; |
| 8439 | 882 |
by (case_tac "n" 1); |
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
883 |
by Auto_tac; |
| 3361 | 884 |
qed"take_reduction_less1"; |
885 |
||
886 |
||
| 10835 | 887 |
Goal "!! n.[| x=y; s=t;!! k. k<n ==> seq_take k$y1 << seq_take k$y2|] \ |
888 |
\ ==> seq_take n$(x @@ (s>>y1)) << seq_take n$(y @@ (t>>y2))"; |
|
| 4098 | 889 |
by (auto_tac (claset() addSIs [take_reduction_less1 RS spec RS mp],simpset())); |
| 3361 | 890 |
qed"take_reduction_less"; |
891 |
||
892 |
||
893 |
val prems = goalw thy [seq.take_def] |
|
| 10835 | 894 |
"(!! n. seq_take n$s1 << seq_take n$s2) ==> s1<<s2"; |
| 3361 | 895 |
|
896 |
by (res_inst_tac [("t","s1")] (seq.reach RS subst) 1);
|
|
897 |
by (res_inst_tac [("t","s2")] (seq.reach RS subst) 1);
|
|
898 |
by (rtac (fix_def2 RS ssubst ) 1); |
|
| 3457 | 899 |
by (stac contlub_cfun_fun 1); |
|
4721
c8a8482a8124
renamed is_chain to chain, is_tord to tord, replaced chain_finite by chfin
oheimb
parents:
4716
diff
changeset
|
900 |
by (rtac chain_iterate 1); |
| 3457 | 901 |
by (stac contlub_cfun_fun 1); |
|
4721
c8a8482a8124
renamed is_chain to chain, is_tord to tord, replaced chain_finite by chfin
oheimb
parents:
4716
diff
changeset
|
902 |
by (rtac chain_iterate 1); |
| 3361 | 903 |
by (rtac lub_mono 1); |
| 5291 | 904 |
by (rtac (chain_iterate RS ch2ch_Rep_CFunL) 1); |
905 |
by (rtac (chain_iterate RS ch2ch_Rep_CFunL) 1); |
|
| 3361 | 906 |
by (rtac allI 1); |
907 |
by (resolve_tac prems 1); |
|
908 |
qed"take_lemma_less1"; |
|
909 |
||
910 |
||
| 10835 | 911 |
Goal "(!n. seq_take n$x << seq_take n$x') = (x << x')"; |
| 3361 | 912 |
by (rtac iffI 1); |
| 3457 | 913 |
by (rtac take_lemma_less1 1); |
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
914 |
by Auto_tac; |
| 3457 | 915 |
by (etac monofun_cfun_arg 1); |
| 3361 | 916 |
qed"take_lemma_less"; |
917 |
||
918 |
(* ------------------------------------------------------------------ |
|
919 |
take-lemma proof principles |
|
920 |
------------------------------------------------------------------ *) |
|
| 3071 | 921 |
|
| 5068 | 922 |
Goal "!! Q. [|!! s. [| Forall Q s; A s |] ==> (f s) = (g s) ; \ |
| 3071 | 923 |
\ !! s1 s2 y. [| Forall Q s1; Finite s1; ~ Q y; A (s1 @@ y>>s2)|] \ |
924 |
\ ==> (f (s1 @@ y>>s2)) = (g (s1 @@ y>>s2)) |] \ |
|
925 |
\ ==> A x --> (f x)=(g x)"; |
|
926 |
by (case_tac "Forall Q x" 1); |
|
| 4098 | 927 |
by (auto_tac (claset() addSDs [divide_Seq3],simpset())); |
| 3071 | 928 |
qed"take_lemma_principle1"; |
929 |
||
| 5068 | 930 |
Goal "!! Q. [|!! s. [| Forall Q s; A s |] ==> (f s) = (g s) ; \ |
| 3071 | 931 |
\ !! s1 s2 y. [| Forall Q s1; Finite s1; ~ Q y; A (s1 @@ y>>s2)|] \ |
| 10835 | 932 |
\ ==> ! n. seq_take n$(f (s1 @@ y>>s2)) \ |
933 |
\ = seq_take n$(g (s1 @@ y>>s2)) |] \ |
|
| 3071 | 934 |
\ ==> A x --> (f x)=(g x)"; |
935 |
by (case_tac "Forall Q x" 1); |
|
| 4098 | 936 |
by (auto_tac (claset() addSDs [divide_Seq3],simpset())); |
| 4042 | 937 |
by (resolve_tac seq.take_lemmas 1); |
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
938 |
by Auto_tac; |
| 3071 | 939 |
qed"take_lemma_principle2"; |
940 |
||
941 |
||
942 |
(* Note: in the following proofs the ordering of proof steps is very |
|
943 |
important, as otherwise either (Forall Q s1) would be in the IH as |
|
944 |
assumption (then rule useless) or it is not possible to strengthen |
|
945 |
the IH by doing a forall closure of the sequence t (then rule also useless). |
|
| 9877 | 946 |
This is also the reason why the induction rule (nat_less_induct or nat_induct) has to |
| 3071 | 947 |
to be imbuilt into the rule, as induction has to be done early and the take lemma |
948 |
has to be used in the trivial direction afterwards for the (Forall Q x) case. *) |
|
949 |
||
| 5068 | 950 |
Goal |
| 3071 | 951 |
"!! Q. [|!! s. [| Forall Q s; A s |] ==> (f s) = (g s) ; \ |
| 10835 | 952 |
\ !! s1 s2 y n. [| ! t. A t --> seq_take n$(f t) = seq_take n$(g t);\ |
| 3071 | 953 |
\ Forall Q s1; Finite s1; ~ Q y; A (s1 @@ y>>s2) |] \ |
| 10835 | 954 |
\ ==> seq_take (Suc n)$(f (s1 @@ y>>s2)) \ |
955 |
\ = seq_take (Suc n)$(g (s1 @@ y>>s2)) |] \ |
|
| 3071 | 956 |
\ ==> A x --> (f x)=(g x)"; |
| 3457 | 957 |
by (rtac impI 1); |
| 4042 | 958 |
by (resolve_tac seq.take_lemmas 1); |
| 3457 | 959 |
by (rtac mp 1); |
960 |
by (assume_tac 2); |
|
| 3071 | 961 |
by (res_inst_tac [("x","x")] spec 1);
|
| 3457 | 962 |
by (rtac nat_induct 1); |
| 3071 | 963 |
by (Simp_tac 1); |
| 3457 | 964 |
by (rtac allI 1); |
| 3071 | 965 |
by (case_tac "Forall Q xa" 1); |
| 4098 | 966 |
by (SELECT_GOAL (auto_tac (claset() addSIs [seq_take_lemma RS iffD2 RS spec], |
967 |
simpset())) 1); |
|
968 |
by (auto_tac (claset() addSDs [divide_Seq3],simpset())); |
|
| 3071 | 969 |
qed"take_lemma_induct"; |
970 |
||
971 |
||
| 5068 | 972 |
Goal |
| 3071 | 973 |
"!! Q. [|!! s. [| Forall Q s; A s |] ==> (f s) = (g s) ; \ |
| 10835 | 974 |
\ !! s1 s2 y n. [| ! t m. m < n --> A t --> seq_take m$(f t) = seq_take m$(g t);\ |
| 3071 | 975 |
\ Forall Q s1; Finite s1; ~ Q y; A (s1 @@ y>>s2) |] \ |
| 10835 | 976 |
\ ==> seq_take n$(f (s1 @@ y>>s2)) \ |
977 |
\ = seq_take n$(g (s1 @@ y>>s2)) |] \ |
|
| 3071 | 978 |
\ ==> A x --> (f x)=(g x)"; |
| 3457 | 979 |
by (rtac impI 1); |
| 4042 | 980 |
by (resolve_tac seq.take_lemmas 1); |
| 3457 | 981 |
by (rtac mp 1); |
982 |
by (assume_tac 2); |
|
| 3071 | 983 |
by (res_inst_tac [("x","x")] spec 1);
|
| 9877 | 984 |
by (rtac nat_less_induct 1); |
| 3457 | 985 |
by (rtac allI 1); |
| 3071 | 986 |
by (case_tac "Forall Q xa" 1); |
| 4098 | 987 |
by (SELECT_GOAL (auto_tac (claset() addSIs [seq_take_lemma RS iffD2 RS spec], |
988 |
simpset())) 1); |
|
989 |
by (auto_tac (claset() addSDs [divide_Seq3],simpset())); |
|
| 3071 | 990 |
qed"take_lemma_less_induct"; |
991 |
||
| 3275 | 992 |
|
993 |
(* |
|
| 3521 | 994 |
local |
995 |
||
996 |
fun qnt_tac i (tac, var) = tac THEN res_inst_tac [("x", var)] spec i;
|
|
997 |
||
998 |
fun add_frees tsig = |
|
999 |
let |
|
1000 |
fun add (Free (x, T), vars) = |
|
1001 |
if Type.of_sort tsig (T, HOLogic.termS) then x ins vars |
|
1002 |
else vars |
|
1003 |
| add (Abs (_, _, t), vars) = add (t, vars) |
|
1004 |
| add (t $ u, vars) = add (t, add (u, vars)) |
|
1005 |
| add (_, vars) = vars; |
|
1006 |
in add end; |
|
1007 |
||
1008 |
||
1009 |
in |
|
1010 |
||
1011 |
(*Generalizes over all free variables, with the named var outermost.*) |
|
1012 |
fun all_frees_tac x i thm = |
|
1013 |
let |
|
| 14643 | 1014 |
val tsig = Sign.tsig_of (Thm.sign_of_thm thm); |
| 15570 | 1015 |
val frees = add_frees tsig (List.nth (prems_of thm, i - 1), [x]); |
| 3521 | 1016 |
val frees' = sort (op >) (frees \ x) @ [x]; |
1017 |
in |
|
1018 |
foldl (qnt_tac i) (all_tac, frees') thm |
|
1019 |
end; |
|
1020 |
||
1021 |
end; |
|
1022 |
||
| 3275 | 1023 |
|
| 5068 | 1024 |
Goal |
| 3275 | 1025 |
"!! Q. [|!! s h1 h2. [| Forall Q s; A s h1 h2|] ==> (f s h1 h2) = (g s h1 h2) ; \ |
| 10835 | 1026 |
\ !! s1 s2 y n. [| ! t h1 h2 m. m < n --> (A t h1 h2) --> seq_take m$(f t h1 h2) = seq_take m$(g t h1 h2);\ |
| 3275 | 1027 |
\ Forall Q s1; Finite s1; ~ Q y; A (s1 @@ y>>s2) h1 h2|] \ |
| 10835 | 1028 |
\ ==> seq_take n$(f (s1 @@ y>>s2) h1 h2) \ |
1029 |
\ = seq_take n$(g (s1 @@ y>>s2) h1 h2) |] \ |
|
| 3275 | 1030 |
\ ==> ! h1 h2. (A x h1 h2) --> (f x h1 h2)=(g x h1 h2)"; |
1031 |
by (strip_tac 1); |
|
| 4042 | 1032 |
by (resolve_tac seq.take_lemmas 1); |
| 3457 | 1033 |
by (rtac mp 1); |
1034 |
by (assume_tac 2); |
|
| 3275 | 1035 |
by (res_inst_tac [("x","h2a")] spec 1);
|
1036 |
by (res_inst_tac [("x","h1a")] spec 1);
|
|
1037 |
by (res_inst_tac [("x","x")] spec 1);
|
|
| 9877 | 1038 |
by (rtac nat_less_induct 1); |
| 3457 | 1039 |
by (rtac allI 1); |
| 3275 | 1040 |
by (case_tac "Forall Q xa" 1); |
| 4098 | 1041 |
by (SELECT_GOAL (auto_tac (claset() addSIs [seq_take_lemma RS iffD2 RS spec], |
1042 |
simpset())) 1); |
|
1043 |
by (auto_tac (claset() addSDs [divide_Seq3],simpset())); |
|
| 3275 | 1044 |
qed"take_lemma_less_induct"; |
1045 |
||
1046 |
||
1047 |
||
| 5068 | 1048 |
Goal |
| 3275 | 1049 |
"!! Q. [|!! s. Forall Q s ==> P ((f s) = (g s)) ; \ |
| 10835 | 1050 |
\ !! s1 s2 y n. [| ! t m. m < n --> P (seq_take m$(f t) = seq_take m$(g t));\ |
| 3275 | 1051 |
\ Forall Q s1; Finite s1; ~ Q y|] \ |
| 10835 | 1052 |
\ ==> P (seq_take n$(f (s1 @@ y>>s2)) \ |
1053 |
\ = seq_take n$(g (s1 @@ y>>s2))) |] \ |
|
| 3275 | 1054 |
\ ==> P ((f x)=(g x))"; |
1055 |
||
1056 |
by (res_inst_tac [("t","f x = g x"),
|
|
| 10835 | 1057 |
("s","!n. seq_take n$(f x) = seq_take n$(g x)")] subst 1);
|
| 3457 | 1058 |
by (rtac seq_take_lemma 1); |
| 3275 | 1059 |
|
1060 |
wie ziehe ich n durch P, d.h. evtl. ns in P muessen umbenannt werden..... |
|
1061 |
||
1062 |
||
1063 |
FIX |
|
1064 |
||
| 9877 | 1065 |
by (rtac nat_less_induct 1); |
| 3457 | 1066 |
by (rtac allI 1); |
| 3275 | 1067 |
by (case_tac "Forall Q xa" 1); |
| 4098 | 1068 |
by (SELECT_GOAL (auto_tac (claset() addSIs [seq_take_lemma RS iffD2 RS spec], |
1069 |
simpset())) 1); |
|
1070 |
by (auto_tac (claset() addSDs [divide_Seq3],simpset())); |
|
| 3275 | 1071 |
qed"take_lemma_less_induct"; |
1072 |
||
1073 |
||
1074 |
*) |
|
1075 |
||
1076 |
||
| 5068 | 1077 |
Goal |
| 3071 | 1078 |
"!! Q. [| A UU ==> (f UU) = (g UU) ; \ |
1079 |
\ A nil ==> (f nil) = (g nil) ; \ |
|
| 10835 | 1080 |
\ !! s y n. [| ! t. A t --> seq_take n$(f t) = seq_take n$(g t);\ |
| 3071 | 1081 |
\ A (y>>s) |] \ |
| 10835 | 1082 |
\ ==> seq_take (Suc n)$(f (y>>s)) \ |
1083 |
\ = seq_take (Suc n)$(g (y>>s)) |] \ |
|
| 3071 | 1084 |
\ ==> A x --> (f x)=(g x)"; |
| 3457 | 1085 |
by (rtac impI 1); |
| 4042 | 1086 |
by (resolve_tac seq.take_lemmas 1); |
| 3457 | 1087 |
by (rtac mp 1); |
1088 |
by (assume_tac 2); |
|
| 3071 | 1089 |
by (res_inst_tac [("x","x")] spec 1);
|
| 3457 | 1090 |
by (rtac nat_induct 1); |
| 3071 | 1091 |
by (Simp_tac 1); |
| 3457 | 1092 |
by (rtac allI 1); |
| 3071 | 1093 |
by (Seq_case_simp_tac "xa" 1); |
1094 |
qed"take_lemma_in_eq_out"; |
|
1095 |
||
1096 |
||
1097 |
(* ------------------------------------------------------------------------------------ *) |
|
1098 |
||
1099 |
section "alternative take_lemma proofs"; |
|
1100 |
||
1101 |
||
1102 |
(* --------------------------------------------------------------- *) |
|
1103 |
(* Alternative Proof of FilterPQ *) |
|
1104 |
(* --------------------------------------------------------------- *) |
|
1105 |
||
1106 |
Delsimps [FilterPQ]; |
|
1107 |
||
1108 |
||
1109 |
(* In general: How to do this case without the same adm problems |
|
1110 |
as for the entire proof ? *) |
|
| 5068 | 1111 |
Goal "Forall (%x.~(P x & Q x)) s \ |
| 10835 | 1112 |
\ --> Filter P$(Filter Q$s) =\ |
1113 |
\ Filter (%x. P x & Q x)$s"; |
|
| 3071 | 1114 |
|
1115 |
by (Seq_induct_tac "s" [Forall_def,sforall_def] 1); |
|
1116 |
qed"Filter_lemma1"; |
|
1117 |
||
| 6161 | 1118 |
Goal "Finite s ==> \ |
| 3071 | 1119 |
\ (Forall (%x. (~P x) | (~ Q x)) s \ |
| 10835 | 1120 |
\ --> Filter P$(Filter Q$s) = nil)"; |
| 3071 | 1121 |
by (Seq_Finite_induct_tac 1); |
1122 |
qed"Filter_lemma2"; |
|
1123 |
||
| 6161 | 1124 |
Goal "Finite s ==> \ |
| 3071 | 1125 |
\ Forall (%x. (~P x) | (~ Q x)) s \ |
| 10835 | 1126 |
\ --> Filter (%x. P x & Q x)$s = nil"; |
| 3071 | 1127 |
by (Seq_Finite_induct_tac 1); |
1128 |
qed"Filter_lemma3"; |
|
1129 |
||
1130 |
||
| 10835 | 1131 |
Goal "Filter P$(Filter Q$s) = Filter (%x. P x & Q x)$s"; |
| 3842 | 1132 |
by (res_inst_tac [("A1","%x. True")
|
| 3275 | 1133 |
,("Q1","%x.~(P x & Q x)"),("x1","s")]
|
| 3071 | 1134 |
(take_lemma_induct RS mp) 1); |
| 5976 | 1135 |
(* better support for A = %x. True *) |
| 3071 | 1136 |
by (Fast_tac 3); |
| 4098 | 1137 |
by (asm_full_simp_tac (simpset() addsimps [Filter_lemma1]) 1); |
| 4833 | 1138 |
by (asm_full_simp_tac (simpset() addsimps [Filter_lemma2,Filter_lemma3]) 1); |
| 3071 | 1139 |
qed"FilterPQ_takelemma"; |
1140 |
||
1141 |
Addsimps [FilterPQ]; |
|
1142 |
||
1143 |
||
1144 |
(* --------------------------------------------------------------- *) |
|
1145 |
(* Alternative Proof of MapConc *) |
|
1146 |
(* --------------------------------------------------------------- *) |
|
1147 |
||
| 3275 | 1148 |
|
| 3071 | 1149 |
|
| 10835 | 1150 |
Goal "Map f$(x@@y) = (Map f$x) @@ (Map f$y)"; |
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
1151 |
by (res_inst_tac [("A1","%x. True"), ("x1","x")]
|
|
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
1152 |
(take_lemma_in_eq_out RS mp) 1); |
|
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4098
diff
changeset
|
1153 |
by Auto_tac; |
| 3071 | 1154 |
qed"MapConc_takelemma"; |
1155 |
||
1156 |