src/HOL/Set_Interval.thy
changeset 69235 0e156963b636
parent 69198 9218b7652839
child 69276 3d954183b707
     1.1 --- a/src/HOL/Set_Interval.thy	Sun Nov 04 17:19:56 2018 +0100
     1.2 +++ b/src/HOL/Set_Interval.thy	Mon Nov 05 10:02:21 2018 +0100
     1.3 @@ -1345,25 +1345,6 @@
     1.4    thus "(\<exists>f. bij_betw f A B)" by blast
     1.5  qed (auto simp: bij_betw_same_card)
     1.6  
     1.7 -lemma inj_on_iff_card_le:
     1.8 -  assumes FIN: "finite A" and FIN': "finite B"
     1.9 -  shows "(\<exists>f. inj_on f A \<and> f ` A \<le> B) = (card A \<le> card B)"
    1.10 -proof (safe intro!: card_inj_on_le)
    1.11 -  assume *: "card A \<le> card B"
    1.12 -  obtain f where 1: "inj_on f A" and 2: "f ` A = {0 ..< card A}"
    1.13 -  using FIN ex_bij_betw_finite_nat unfolding bij_betw_def by force
    1.14 -  moreover obtain g where "inj_on g {0 ..< card B}" and 3: "g ` {0 ..< card B} = B"
    1.15 -  using FIN' ex_bij_betw_nat_finite unfolding bij_betw_def by force
    1.16 -  ultimately have "inj_on g (f ` A)" using subset_inj_on[of g _ "f ` A"] * by force
    1.17 -  hence "inj_on (g \<circ> f) A" using 1 comp_inj_on by blast
    1.18 -  moreover
    1.19 -  {have "{0 ..< card A} \<le> {0 ..< card B}" using * by force
    1.20 -   with 2 have "f ` A  \<le> {0 ..< card B}" by blast
    1.21 -   hence "(g \<circ> f) ` A \<le> B" unfolding comp_def using 3 by force
    1.22 -  }
    1.23 -  ultimately show "(\<exists>f. inj_on f A \<and> f ` A \<le> B)" by blast
    1.24 -qed (insert assms, auto)
    1.25 -
    1.26  lemma subset_eq_atLeast0_lessThan_card:
    1.27    fixes n :: nat
    1.28    assumes "N \<subseteq> {0..<n}"
    1.29 @@ -1374,6 +1355,27 @@
    1.30    then show ?thesis by simp
    1.31  qed
    1.32  
    1.33 +text \<open>Relational version of @{thm [source] card_inj_on_le}:\<close>
    1.34 +lemma card_le_if_inj_on_rel:
    1.35 +assumes "finite B"
    1.36 +  "\<And>a. a \<in> A \<Longrightarrow> \<exists>b. b\<in>B \<and> r a b"
    1.37 +  "\<And>a1 a2 b. \<lbrakk> a1 \<in> A;  a2 \<in> A;  b \<in> B;  r a1 b;  r a2 b \<rbrakk> \<Longrightarrow> a1 = a2"
    1.38 +shows "card A \<le> card B"
    1.39 +proof -
    1.40 +  let ?P = "\<lambda>a b. b \<in> B \<and> r a b"
    1.41 +  let ?f = "\<lambda>a. SOME b. ?P a b"
    1.42 +  have 1: "?f ` A \<subseteq> B"  by (auto intro: someI2_ex[OF assms(2)])
    1.43 +  have "inj_on ?f A"
    1.44 +  proof (auto simp: inj_on_def)
    1.45 +    fix a1 a2 assume asms: "a1 \<in> A" "a2 \<in> A" "?f a1 = ?f a2"
    1.46 +    have 0: "?f a1 \<in> B" using "1" \<open>a1 \<in> A\<close> by blast
    1.47 +    have 1: "r a1 (?f a1)" using someI_ex[OF assms(2)[OF \<open>a1 \<in> A\<close>]] by blast
    1.48 +    have 2: "r a2 (?f a1)" using someI_ex[OF assms(2)[OF \<open>a2 \<in> A\<close>]] asms(3) by auto
    1.49 +    show "a1 = a2" using assms(3)[OF asms(1,2) 0 1 2] .
    1.50 +  qed
    1.51 +  with 1 show ?thesis using card_inj_on_le[of ?f A B] assms(1) by simp
    1.52 +qed
    1.53 +
    1.54  
    1.55  subsection \<open>Intervals of integers\<close>
    1.56