178 fixes z |
175 fixes z |
179 assumes a: "x \<approx> y" |
176 assumes a: "x \<approx> y" |
180 shows "(z memb x) = (z memb y)" |
177 shows "(z memb x) = (z memb y)" |
181 using a by induct auto |
178 using a by induct auto |
182 |
179 |
183 lemma ho_memb_rsp[quot_rsp]: |
180 lemma ho_memb_rsp[quotient_rsp]: |
184 "(op = ===> (op \<approx> ===> op =)) (op memb) (op memb)" |
181 "(op = ===> (op \<approx> ===> op =)) (op memb) (op memb)" |
185 by (simp add: memb_rsp) |
182 by (simp add: memb_rsp) |
186 |
183 |
187 lemma card1_rsp: |
184 lemma card1_rsp: |
188 fixes a b :: "'a list" |
185 fixes a b :: "'a list" |
189 assumes e: "a \<approx> b" |
186 assumes e: "a \<approx> b" |
190 shows "card1 a = card1 b" |
187 shows "card1 a = card1 b" |
191 using e by induct (simp_all add:memb_rsp) |
188 using e by induct (simp_all add:memb_rsp) |
192 |
189 |
193 lemma ho_card1_rsp[quot_rsp]: |
190 lemma ho_card1_rsp[quotient_rsp]: |
194 "(op \<approx> ===> op =) card1 card1" |
191 "(op \<approx> ===> op =) card1 card1" |
195 by (simp add: card1_rsp) |
192 by (simp add: card1_rsp) |
196 |
193 |
197 lemma cons_rsp[quot_rsp]: |
194 lemma cons_rsp[quotient_rsp]: |
198 fixes z |
195 fixes z |
199 assumes a: "xs \<approx> ys" |
196 assumes a: "xs \<approx> ys" |
200 shows "(z # xs) \<approx> (z # ys)" |
197 shows "(z # xs) \<approx> (z # ys)" |
201 using a by (rule list_eq.intros(5)) |
198 using a by (rule list_eq.intros(5)) |
202 |
199 |
203 lemma ho_cons_rsp[quot_rsp]: |
200 lemma ho_cons_rsp[quotient_rsp]: |
204 "(op = ===> op \<approx> ===> op \<approx>) op # op #" |
201 "(op = ===> op \<approx> ===> op \<approx>) op # op #" |
205 by (simp add: cons_rsp) |
202 by (simp add: cons_rsp) |
206 |
203 |
207 lemma append_rsp_fst: |
204 lemma append_rsp_fst: |
208 assumes a : "l1 \<approx> l2" |
205 assumes a : "l1 \<approx> l2" |
255 apply (rule append_rsp_fst) |
252 apply (rule append_rsp_fst) |
256 using b apply (assumption) |
253 using b apply (assumption) |
257 apply (rule append_sym_rsp) |
254 apply (rule append_sym_rsp) |
258 done |
255 done |
259 |
256 |
260 lemma ho_append_rsp[quot_rsp]: |
257 lemma ho_append_rsp[quotient_rsp]: |
261 "(op \<approx> ===> op \<approx> ===> op \<approx>) op @ op @" |
258 "(op \<approx> ===> op \<approx> ===> op \<approx>) op @ op @" |
262 by (simp add: append_rsp) |
259 by (simp add: append_rsp) |
263 |
260 |
264 lemma map_rsp: |
261 lemma map_rsp: |
265 assumes a: "a \<approx> b" |
262 assumes a: "a \<approx> b" |
267 using a |
264 using a |
268 apply (induct) |
265 apply (induct) |
269 apply(auto intro: list_eq.intros) |
266 apply(auto intro: list_eq.intros) |
270 done |
267 done |
271 |
268 |
272 lemma ho_map_rsp[quot_rsp]: |
269 lemma ho_map_rsp[quotient_rsp]: |
273 "(op = ===> op \<approx> ===> op \<approx>) map map" |
270 "(op = ===> op \<approx> ===> op \<approx>) map map" |
274 by (simp add: map_rsp) |
271 by (simp add: map_rsp) |
275 |
272 |
276 lemma map_append: |
273 lemma map_append: |
277 "(map f (a @ b)) \<approx> (map f a) @ (map f b)" |
274 "(map f (a @ b)) \<approx> (map f a) @ (map f b)" |
278 by simp (rule list_eq_refl) |
275 by simp (rule list_eq_refl) |
279 |
276 |
280 lemma ho_fold_rsp[quot_rsp]: |
277 lemma ho_fold_rsp[quotient_rsp]: |
281 "(op = ===> op = ===> op = ===> op \<approx> ===> op =) fold1 fold1" |
278 "(op = ===> op = ===> op = ===> op \<approx> ===> op =) fold1 fold1" |
282 apply (auto simp add: FUN_REL_EQ) |
279 apply (auto simp add: FUN_REL_EQ) |
283 apply (case_tac "rsp_fold x") |
280 apply (case_tac "rsp_fold x") |
284 prefer 2 |
281 prefer 2 |
285 apply (erule_tac list_eq.induct) |
282 apply (erule_tac list_eq.induct) |
295 ML {* val rsp_thms = |
292 ML {* val rsp_thms = |
296 @{thms ho_memb_rsp ho_cons_rsp ho_card1_rsp ho_map_rsp ho_append_rsp ho_fold_rsp} *} |
293 @{thms ho_memb_rsp ho_cons_rsp ho_card1_rsp ho_map_rsp ho_append_rsp ho_fold_rsp} *} |
297 |
294 |
298 ML {* val (rty, rel, rel_refl, rel_eqv) = lookup_quot_data @{context} qty *} |
295 ML {* val (rty, rel, rel_refl, rel_eqv) = lookup_quot_data @{context} qty *} |
299 ML {* val (trans2, reps_same, absrep, quot) = lookup_quot_thms @{context} "fset"; *} |
296 ML {* val (trans2, reps_same, absrep, quot) = lookup_quot_thms @{context} "fset"; *} |
300 ML {* fun lift_tac_fset lthy t = lift_tac lthy t [rel_eqv] [quot] *} |
297 ML {* fun lift_tac_fset lthy t = lift_tac lthy t [rel_eqv] *} |
301 |
298 |
302 lemma "IN x EMPTY = False" |
299 lemma "IN x EMPTY = False" |
303 apply(tactic {* procedure_tac @{context} @{thm m1} 1 *}) |
300 apply(tactic {* procedure_tac @{context} @{thm m1} 1 *}) |
304 apply(tactic {* regularize_tac @{context} [rel_eqv] 1 *}) |
301 apply(tactic {* regularize_tac @{context} [rel_eqv] 1 *}) |
305 apply(tactic {* all_inj_repabs_tac @{context} [quot] [rel_refl] [trans2] 1 *}) |
302 apply(tactic {* all_inj_repabs_tac @{context} [rel_refl] [trans2] 1 *}) |
306 apply(tactic {* clean_tac @{context} [quot] 1*}) |
303 apply(tactic {* clean_tac @{context} 1*}) |
307 done |
304 done |
308 |
305 |
309 lemma "IN x (INSERT y xa) = (x = y \<or> IN x xa)" |
306 lemma "IN x (INSERT y xa) = (x = y \<or> IN x xa)" |
310 by (tactic {* lift_tac_fset @{context} @{thm m2} 1 *}) |
307 by (tactic {* lift_tac_fset @{context} @{thm m2} 1 *}) |
311 |
308 |
328 lemma "FOLD f g (z::'b) (INSERT a x) = |
325 lemma "FOLD f g (z::'b) (INSERT a x) = |
329 (if rsp_fold f then if IN a x then FOLD f g z x else f (g a) (FOLD f g z x) else z)" |
326 (if rsp_fold f then if IN a x then FOLD f g z x else f (g a) (FOLD f g z x) else z)" |
330 apply(tactic {* lift_tac_fset @{context} @{thm fold1.simps(2)} 1 *}) |
327 apply(tactic {* lift_tac_fset @{context} @{thm fold1.simps(2)} 1 *}) |
331 done |
328 done |
332 |
329 |
333 ML {* fun inj_repabs_tac_fset lthy = inj_repabs_tac lthy [quot] [rel_refl] [trans2] *} |
330 ML {* fun inj_repabs_tac_fset lthy = inj_repabs_tac lthy [rel_refl] [trans2] *} |
334 |
331 |
335 lemma "fmap f (FUNION (x::'b fset) (xa::'b fset)) = FUNION (fmap f x) (fmap f xa)" |
332 lemma "fmap f (FUNION (x::'b fset) (xa::'b fset)) = FUNION (fmap f x) (fmap f xa)" |
336 apply (tactic {* lift_tac_fset @{context} @{thm map_append} 1 *}) |
333 apply (tactic {* lift_tac_fset @{context} @{thm map_append} 1 *}) |
337 done |
334 done |
338 |
335 |
346 lemma "\<lbrakk>P EMPTY; \<And>a x. P x \<Longrightarrow> P (INSERT a x)\<rbrakk> \<Longrightarrow> P l" |
343 lemma "\<lbrakk>P EMPTY; \<And>a x. P x \<Longrightarrow> P (INSERT a x)\<rbrakk> \<Longrightarrow> P l" |
347 apply (tactic {* (ObjectLogic.full_atomize_tac THEN' gen_frees_tac @{context}) 1 *}) |
344 apply (tactic {* (ObjectLogic.full_atomize_tac THEN' gen_frees_tac @{context}) 1 *}) |
348 apply(tactic {* procedure_tac @{context} @{thm list.induct} 1 *}) |
345 apply(tactic {* procedure_tac @{context} @{thm list.induct} 1 *}) |
349 apply(tactic {* regularize_tac @{context} [rel_eqv] 1 *}) |
346 apply(tactic {* regularize_tac @{context} [rel_eqv] 1 *}) |
350 prefer 2 |
347 prefer 2 |
351 apply(tactic {* clean_tac @{context} [quot] 1 *}) |
348 apply(tactic {* clean_tac @{context} 1 *}) |
352 apply(tactic {* inj_repabs_tac_fset @{context} 1*}) (* 3 *) (* Ball-Ball *) |
349 apply(tactic {* inj_repabs_tac_fset @{context} 1*}) (* 3 *) (* Ball-Ball *) |
353 apply(tactic {* inj_repabs_tac_fset @{context} 1*}) (* 9 *) (* Rep-Abs-elim - can be complex Rep-Abs *) |
350 apply(tactic {* inj_repabs_tac_fset @{context} 1*}) (* 9 *) (* Rep-Abs-elim - can be complex Rep-Abs *) |
354 apply(tactic {* inj_repabs_tac_fset @{context} 1*}) (* 2 *) (* lam-lam-elim for R = (===>) *) |
351 apply(tactic {* inj_repabs_tac_fset @{context} 1*}) (* 2 *) (* lam-lam-elim for R = (===>) *) |
355 apply(tactic {* inj_repabs_tac_fset @{context} 1*}) (* 3 *) (* Ball-Ball *) |
352 apply(tactic {* inj_repabs_tac_fset @{context} 1*}) (* 3 *) (* Ball-Ball *) |
356 apply(tactic {* inj_repabs_tac_fset @{context} 1*}) (* 9 *) (* Rep-Abs-elim - can be complex Rep-Abs *) |
353 apply(tactic {* inj_repabs_tac_fset @{context} 1*}) (* 9 *) (* Rep-Abs-elim - can be complex Rep-Abs *) |
429 INSERT2 :: "'a \<Rightarrow> 'a fset2 \<Rightarrow> 'a fset2" |
429 INSERT2 :: "'a \<Rightarrow> 'a fset2 \<Rightarrow> 'a fset2" |
430 where |
430 where |
431 "INSERT2 \<equiv> op #" |
431 "INSERT2 \<equiv> op #" |
432 |
432 |
433 ML {* val quot = @{thms QUOTIENT_fset QUOTIENT_fset2} *} |
433 ML {* val quot = @{thms QUOTIENT_fset QUOTIENT_fset2} *} |
434 ML {* fun inj_repabs_tac_fset lthy = inj_repabs_tac lthy quot [rel_refl] [trans2] *} |
434 ML {* fun inj_repabs_tac_fset lthy = inj_repabs_tac lthy [rel_refl] [trans2] *} |
435 ML {* fun lift_tac_fset lthy t = lift_tac lthy t [rel_eqv] quot *} |
435 ML {* fun lift_tac_fset lthy t = lift_tac lthy t [rel_eqv] *} |
436 |
436 |
437 lemma "P (x :: 'a fset2) (EMPTY :: 'c fset) \<Longrightarrow> (\<And>e t. P x t \<Longrightarrow> P x (INSERT e t)) \<Longrightarrow> P x l" |
437 lemma "P (x :: 'a fset2) (EMPTY :: 'c fset) \<Longrightarrow> (\<And>e t. P x t \<Longrightarrow> P x (INSERT e t)) \<Longrightarrow> P x l" |
438 apply (tactic {* lift_tac_fset @{context} @{thm list_induct_part} 1 *}) |
438 apply (tactic {* lift_tac_fset @{context} @{thm list_induct_part} 1 *}) |
439 done |
439 done |
440 |
440 |
451 fset_case::"'a \<Rightarrow> ('b \<Rightarrow> 'b fset \<Rightarrow> 'a) \<Rightarrow> 'b fset \<Rightarrow> 'a" |
451 fset_case::"'a \<Rightarrow> ('b \<Rightarrow> 'b fset \<Rightarrow> 'a) \<Rightarrow> 'b fset \<Rightarrow> 'a" |
452 where |
452 where |
453 "fset_case \<equiv> list_case" |
453 "fset_case \<equiv> list_case" |
454 |
454 |
455 (* Probably not true without additional assumptions about the function *) |
455 (* Probably not true without additional assumptions about the function *) |
456 lemma list_rec_rsp[quot_rsp]: |
456 lemma list_rec_rsp[quotient_rsp]: |
457 "(op = ===> (op = ===> op \<approx> ===> op =) ===> op \<approx> ===> op =) list_rec list_rec" |
457 "(op = ===> (op = ===> op \<approx> ===> op =) ===> op \<approx> ===> op =) list_rec list_rec" |
458 apply (auto simp add: FUN_REL_EQ) |
458 apply (auto simp add: FUN_REL_EQ) |
459 apply (erule_tac list_eq.induct) |
459 apply (erule_tac list_eq.induct) |
460 apply (simp_all) |
460 apply (simp_all) |
461 sorry |
461 sorry |
462 |
462 |
463 lemma list_case_rsp[quot_rsp]: |
463 lemma list_case_rsp[quotient_rsp]: |
464 "(op = ===> (op = ===> op \<approx> ===> op =) ===> op \<approx> ===> op =) list_case list_case" |
464 "(op = ===> (op = ===> op \<approx> ===> op =) ===> op \<approx> ===> op =) list_case list_case" |
465 apply (auto simp add: FUN_REL_EQ) |
465 apply (auto simp add: FUN_REL_EQ) |
466 sorry |
466 sorry |
467 |
467 |
468 ML {* val rsp_thms = @{thms list_rec_rsp list_case_rsp} @ rsp_thms *} |
468 ML {* val rsp_thms = @{thms list_rec_rsp list_case_rsp} @ rsp_thms *} |
469 ML {* fun lift_tac_fset lthy t = lift_tac lthy t [rel_eqv] quot *} |
469 ML {* fun lift_tac_fset lthy t = lift_tac lthy t [rel_eqv] *} |
470 |
470 |
471 lemma "fset_rec (f1::'t) x (INSERT a xa) = x a xa (fset_rec f1 x xa)" |
471 lemma "fset_rec (f1::'t) x (INSERT a xa) = x a xa (fset_rec f1 x xa)" |
472 apply (tactic {* lift_tac_fset @{context} @{thm list.recs(2)} 1 *}) |
472 apply (tactic {* lift_tac_fset @{context} @{thm list.recs(2)} 1 *}) |
473 done |
473 done |
474 |
474 |