src/HOL/Finite_Set.thy
changeset 44890 22f665a2e91c
parent 44835 ff6b9eb9c5ef
child 44919 482f1807976e
equal deleted inserted replaced
44889:340df9f3491f 44890:22f665a2e91c
   122   thus ?thesis by blast
   122   thus ?thesis by blast
   123 qed
   123 qed
   124 
   124 
   125 lemma finite_Collect_less_nat [iff]:
   125 lemma finite_Collect_less_nat [iff]:
   126   "finite {n::nat. n < k}"
   126   "finite {n::nat. n < k}"
   127   by (fastsimp simp: finite_conv_nat_seg_image)
   127   by (fastforce simp: finite_conv_nat_seg_image)
   128 
   128 
   129 lemma finite_Collect_le_nat [iff]:
   129 lemma finite_Collect_le_nat [iff]:
   130   "finite {n::nat. n \<le> k}"
   130   "finite {n::nat. n \<le> k}"
   131   by (simp add: le_eq_less_or_eq Collect_disj_eq)
   131   by (simp add: le_eq_less_or_eq Collect_disj_eq)
   132 
   132 
  2038   show ?thesis
  2038   show ?thesis
  2039   proof (intro exI conjI)
  2039   proof (intro exI conjI)
  2040     show "A = insert b (A-{b})" using b by blast
  2040     show "A = insert b (A-{b})" using b by blast
  2041     show "b \<notin> A - {b}" by blast
  2041     show "b \<notin> A - {b}" by blast
  2042     show "card (A - {b}) = k" and "k = 0 \<longrightarrow> A - {b} = {}"
  2042     show "card (A - {b}) = k" and "k = 0 \<longrightarrow> A - {b} = {}"
  2043       using assms b fin by(fastsimp dest:mk_disjoint_insert)+
  2043       using assms b fin by(fastforce dest:mk_disjoint_insert)+
  2044   qed
  2044   qed
  2045 qed
  2045 qed
  2046 
  2046 
  2047 lemma card_Suc_eq:
  2047 lemma card_Suc_eq:
  2048   "(card A = Suc k) =
  2048   "(card A = Suc k) =
  2054  apply(auto intro:ccontr)
  2054  apply(auto intro:ccontr)
  2055 done
  2055 done
  2056 
  2056 
  2057 lemma card_le_Suc_iff: "finite A \<Longrightarrow>
  2057 lemma card_le_Suc_iff: "finite A \<Longrightarrow>
  2058   Suc n \<le> card A = (\<exists>a B. A = insert a B \<and> a \<notin> B \<and> n \<le> card B \<and> finite B)"
  2058   Suc n \<le> card A = (\<exists>a B. A = insert a B \<and> a \<notin> B \<and> n \<le> card B \<and> finite B)"
  2059 by (fastsimp simp: card_Suc_eq less_eq_nat.simps(2) insert_eq_iff
  2059 by (fastforce simp: card_Suc_eq less_eq_nat.simps(2) insert_eq_iff
  2060   dest: subset_singletonD split: nat.splits if_splits)
  2060   dest: subset_singletonD split: nat.splits if_splits)
  2061 
  2061 
  2062 lemma finite_fun_UNIVD2:
  2062 lemma finite_fun_UNIVD2:
  2063   assumes fin: "finite (UNIV :: ('a \<Rightarrow> 'b) set)"
  2063   assumes fin: "finite (UNIV :: ('a \<Rightarrow> 'b) set)"
  2064   shows "finite (UNIV :: 'b set)"
  2064   shows "finite (UNIV :: 'b set)"
  2240 shows "finite(UNIV:: 'a set) \<Longrightarrow> surj f \<Longrightarrow> inj f"
  2240 shows "finite(UNIV:: 'a set) \<Longrightarrow> surj f \<Longrightarrow> inj f"
  2241 by (blast intro: finite_surj_inj subset_UNIV)
  2241 by (blast intro: finite_surj_inj subset_UNIV)
  2242 
  2242 
  2243 lemma finite_UNIV_inj_surj: fixes f :: "'a \<Rightarrow> 'a"
  2243 lemma finite_UNIV_inj_surj: fixes f :: "'a \<Rightarrow> 'a"
  2244 shows "finite(UNIV:: 'a set) \<Longrightarrow> inj f \<Longrightarrow> surj f"
  2244 shows "finite(UNIV:: 'a set) \<Longrightarrow> inj f \<Longrightarrow> surj f"
  2245 by(fastsimp simp:surj_def dest!: endo_inj_surj)
  2245 by(fastforce simp:surj_def dest!: endo_inj_surj)
  2246 
  2246 
  2247 corollary infinite_UNIV_nat[iff]: "~finite(UNIV::nat set)"
  2247 corollary infinite_UNIV_nat[iff]: "~finite(UNIV::nat set)"
  2248 proof
  2248 proof
  2249   assume "finite(UNIV::nat set)"
  2249   assume "finite(UNIV::nat set)"
  2250   with finite_UNIV_inj_surj[of Suc]
  2250   with finite_UNIV_inj_surj[of Suc]