# HG changeset patch # User paulson # Date 1581937629 0 # Node ID 9edb7fb69bc259a25d9676ed5cbf62b7f5dcf08e # Parent d8fb621fea025baffe9a1a67f99e46287c4dae0e a few new lemmas diff -r d8fb621fea02 -r 9edb7fb69bc2 src/HOL/Library/Ramsey.thy --- a/src/HOL/Library/Ramsey.thy Tue Feb 11 12:55:35 2020 +0000 +++ b/src/HOL/Library/Ramsey.thy Mon Feb 17 11:07:09 2020 +0000 @@ -22,6 +22,12 @@ unfolding numeral_2_eq_2 by (auto simp: nsets_def elim!: card_2_doubletonE) +lemma nsets_doubleton_2_eq [simp]: "[{x, y}]\<^bsup>2\<^esup> = (if x=y then {} else {{x, y}})" + by (auto simp: nsets_2_eq) + +lemma doubleton_in_nsets_2 [simp]: "{x,y} \ [A]\<^bsup>2\<^esup> \ x \ A \ y \ A \ x \ y" + by (auto simp: nsets_2_eq Set.doubleton_eq_iff) + lemma binomial_eq_nsets: "n choose k = card (nsets {0.. nsets {..finite A; card A < r\ \ nsets A r = {}" by (simp add: nsets_eq_empty_iff) lemma nsets_empty_iff: "nsets {} r = (if r=0 then {{}} else {})" @@ -80,6 +86,29 @@ by (auto simp: bij_betw_def inj_on_nsets) qed +lemma nset_image_obtains: + assumes "X \ [f`A]\<^bsup>k\<^esup>" "inj_on f A" + obtains Y where "Y \ [A]\<^bsup>k\<^esup>" "X = f ` Y" + using assms + apply (clarsimp simp add: nsets_def subset_image_iff) + by (metis card_image finite_imageD inj_on_subset) + +lemma nsets_image_funcset: + assumes "g \ S \ T" and "inj_on g S" + shows "(\X. g ` X) \ [S]\<^bsup>k\<^esup> \ [T]\<^bsup>k\<^esup>" + using assms + by (fastforce simp add: nsets_def card_image inj_on_subset subset_iff simp flip: image_subset_iff_funcset) + +lemma nsets_compose_image_funcset: + assumes f: "f \ [T]\<^bsup>k\<^esup> \ D" and "g \ S \ T" and "inj_on g S" + shows "f \ (\X. g ` X) \ [S]\<^bsup>k\<^esup> \ D" +proof - + have "(\X. g ` X) \ [S]\<^bsup>k\<^esup> \ [T]\<^bsup>k\<^esup>" + using assms by (simp add: nsets_image_funcset) + then show ?thesis + using f by fastforce +qed + subsubsection \Partition predicates\ definition partn :: "'a set \ nat \ nat \ 'b set \ bool" diff -r d8fb621fea02 -r 9edb7fb69bc2 src/HOL/Num.thy --- a/src/HOL/Num.thy Tue Feb 11 12:55:35 2020 +0000 +++ b/src/HOL/Num.thy Mon Feb 17 11:07:09 2020 +0000 @@ -1107,8 +1107,11 @@ lemma less_2_cases: "n < 2 \ n = 0 \ n = Suc 0" by (auto simp add: numeral_2_eq_2) +lemma less_2_cases_iff: "n < 2 \ n = 0 \ n = Suc 0" + by (auto simp add: numeral_2_eq_2) + text \Removal of Small Numerals: 0, 1 and (in additive positions) 2.\ -text \bh: Are these rules really a good idea?\ +text \bh: Are these rules really a good idea? LCP: well, it already happens for 0 and 1!\ lemma add_2_eq_Suc [simp]: "2 + n = Suc (Suc n)" by simp