# HG changeset patch # User Cezary Kaliszyk # Date 1287146805 -32400 # Node ID 7bd8013b903fdee835dde124a653760c0552e564 # Parent eebfa0b9389692b579db0d197a8e2f2a4cef1759 FSet: give names to respectfulness theorems, rename list_all2_refl to avoid clash diff -r eebfa0b93896 -r 7bd8013b903f src/HOL/Quotient_Examples/FSet.thy --- a/src/HOL/Quotient_Examples/FSet.thy Thu Oct 14 12:40:14 2010 +0200 +++ b/src/HOL/Quotient_Examples/FSet.thy Fri Oct 15 21:46:45 2010 +0900 @@ -26,7 +26,9 @@ 'a fset = "'a list" / "list_eq" by (rule list_eq_equivp) -text {* Raw definitions *} +text {* Raw definitions of membership, sublist, cardinality, + intersection +*} definition memb :: "'a \ 'a list \ bool" @@ -80,7 +82,7 @@ text {* Composition Quotient *} -lemma list_all2_refl: +lemma list_all2_refl1: shows "(list_all2 op \) r r" by (rule list_all2_refl) (metis equivp_def fset_equivp) @@ -88,7 +90,7 @@ shows "(list_all2 op \ OOO op \) r r" proof have *: "r \ r" by (rule equivp_reflp[OF fset_equivp]) - show "list_all2 op \ r r" by (rule list_all2_refl) + show "list_all2 op \ r r" by (rule list_all2_refl1) with * show "(op \ OO list_all2 op \) r r" .. qed @@ -112,11 +114,11 @@ show "abs_fset (map abs_fset (map rep_fset (rep_fset a))) = a" by (simp add: abs_o_rep[OF Quotient_fset] Quotient_abs_rep[OF Quotient_fset] map_id) have b: "list_all2 op \ (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))" - by (rule list_all2_refl) + by (rule list_all2_refl1) have c: "(op \ OO list_all2 op \) (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))" by (rule, rule equivp_reflp[OF fset_equivp]) (rule b) show "(list_all2 op \ OOO op \) (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))" - by (rule, rule list_all2_refl) (rule c) + by (rule, rule list_all2_refl1) (rule c) show "(list_all2 op \ OOO op \) r s = ((list_all2 op \ OOO op \) r r \ (list_all2 op \ OOO op \) s s \ abs_fset (map abs_fset r) = abs_fset (map abs_fset s))" proof (intro iffI conjI) @@ -148,11 +150,11 @@ have b: "map rep_fset (map abs_fset r) \ map rep_fset (map abs_fset s)" by (rule map_rel_cong[OF d]) have y: "list_all2 op \ (map rep_fset (map abs_fset s)) s" - by (fact rep_abs_rsp_left[OF Quotient_fset_list, OF list_all2_refl[of s]]) + by (fact rep_abs_rsp_left[OF Quotient_fset_list, OF list_all2_refl1[of s]]) have c: "(op \ OO list_all2 op \) (map rep_fset (map abs_fset r)) s" by (rule pred_compI) (rule b, rule y) have z: "list_all2 op \ r (map rep_fset (map abs_fset r))" - by (fact rep_abs_rsp[OF Quotient_fset_list, OF list_all2_refl[of r]]) + by (fact rep_abs_rsp[OF Quotient_fset_list, OF list_all2_refl1[of r]]) then show "(list_all2 op \ OOO op \) r s" using a c pred_compI by simp qed @@ -160,11 +162,11 @@ text {* Respectfullness *} -lemma [quot_respect]: - shows "(op \ ===> op \ ===> op \) op @ op @" - by auto +lemma append_rsp[quot_respect]: + shows "(op \ ===> op \ ===> op \) append append" + by (simp) -lemma [quot_respect]: +lemma sub_list_rsp[quot_respect]: shows "(op \ ===> op \ ===> op =) sub_list sub_list" by (auto simp add: sub_list_def) @@ -173,11 +175,11 @@ by (auto simp add: memb_def) lemma nil_rsp[quot_respect]: - shows "[] \ []" + shows "(op \) Nil Nil" by simp lemma cons_rsp[quot_respect]: - shows "(op = ===> op \ ===> op \) op # op #" + shows "(op = ===> op \ ===> op \) Cons Cons" by simp lemma map_rsp[quot_respect]: @@ -350,7 +352,7 @@ then show ?thesis using f i by auto qed -lemma [quot_respect]: +lemma concat_rsp[quot_respect]: shows "(list_all2 op \ OOO op \ ===> op \) concat concat" proof (rule fun_relI, elim pred_compE) fix a b ba bb @@ -374,7 +376,7 @@ qed lemma [quot_respect]: - "((op =) ===> op \ ===> op \) filter filter" + shows "((op =) ===> op \ ===> op \) filter filter" by auto text {* Distributive lattice with bot *} @@ -420,7 +422,7 @@ quotient_definition "sup \ ('a fset \ 'a fset \ 'a fset)" is - "(op @) \ ('a list \ 'a list \ 'a list)" + "append :: 'a list \ 'a list \ 'a list" abbreviation funion (infixl "|\|" 65) @@ -490,7 +492,7 @@ quotient_definition "finsert :: 'a \ 'a fset \ 'a fset" -is "op #" +is "Cons" syntax "@Finset" :: "args => 'a fset" ("{|(_)|}") @@ -552,7 +554,7 @@ by simp lemma [quot_respect]: - "(op \ ===> list_all2 op \ OOO op \ ===> list_all2 op \ OOO op \) op # op #" + shows "(op \ ===> list_all2 op \ OOO op \ ===> list_all2 op \ OOO op \) Cons Cons" apply auto apply (simp add: set_in_eq) apply (rule_tac b="x # b" in pred_compI) @@ -581,13 +583,13 @@ assumes a:"list_all2 op \ x x'" shows "list_all2 op \ (x @ z) (x' @ z)" using a apply (induct x x' rule: list_induct2') - by simp_all (rule list_all2_refl) + by simp_all (rule list_all2_refl1) lemma append_rsp2_pre1: assumes a:"list_all2 op \ x x'" shows "list_all2 op \ (z @ x) (z @ x')" using a apply (induct x x' arbitrary: z rule: list_induct2') - apply (rule list_all2_refl) + apply (rule list_all2_refl1) apply (simp_all del: list_eq.simps) apply (rule list_all2_app_l) apply (simp_all add: reflp_def) @@ -602,7 +604,7 @@ apply (rule a) using b apply (induct z z' rule: list_induct2') apply (simp_all only: append_Nil2) - apply (rule list_all2_refl) + apply (rule list_all2_refl1) apply simp_all apply (rule append_rsp2_pre1) apply simp @@ -1001,7 +1003,8 @@ shows "S |\| {|a|} = finsert a S" by (subst sup.commute) simp -section {* Induction and Cases rules for finite sets *} + +section {* Induction and Cases rules for fsets *} lemma fset_strong_cases: obtains "xs = {||}" @@ -1256,11 +1259,11 @@ lemma subseteq_filter: shows "ffilter P xs <= ffilter Q xs = (\ x. x |\| xs \ P x \ Q x)" - by (lifting sub_list_filter) + by (descending) (auto simp add: memb_def sub_list_def) lemma eq_ffilter: shows "(ffilter P xs = ffilter Q xs) = (\x. x |\| xs \ P x = Q x)" - by (lifting list_eq_filter) + by (descending) (auto simp add: memb_def) lemma subset_ffilter: shows "(\x. x |\| xs \ P x \ Q x) \ (x |\| xs & \ P x & Q x) \ ffilter P xs < ffilter Q xs" @@ -1269,7 +1272,8 @@ section {* lemmas transferred from Finite_Set theory *} text {* finiteness for finite sets holds *} -lemma finite_fset: "finite (fset_to_set S)" +lemma finite_fset [simp]: + shows "finite (fset_to_set S)" by (induct S) auto lemma fset_choice: