src/HOL/Isar_Examples/Schroeder_Bernstein.thy
changeset 63291 b1d7950285cf
parent 63040 eb4ddd18d635
child 63297 ce995deef4b0
equal deleted inserted replaced
63290:9ac558ab0906 63291:b1d7950285cf
    14   \<^item> @{url "http://planetmath.org/proofofschroederbernsteintheoremusingtarskiknastertheorem"}
    14   \<^item> @{url "http://planetmath.org/proofofschroederbernsteintheoremusingtarskiknastertheorem"}
    15   \<^item> Springer LNCS 828 (cover page)
    15   \<^item> Springer LNCS 828 (cover page)
    16 \<close>
    16 \<close>
    17 
    17 
    18 theorem Schroeder_Bernstein:
    18 theorem Schroeder_Bernstein:
    19   fixes f :: "'a \<Rightarrow> 'b"
    19   fixes f :: \<open>'a \<Rightarrow> 'b\<close>
    20     and g :: "'b \<Rightarrow> 'a"
    20     and g :: \<open>'b \<Rightarrow> 'a\<close>
    21   assumes "inj f" and "inj g"
    21   assumes \<open>inj f\<close> and \<open>inj g\<close>
    22   shows "\<exists>h :: 'a \<Rightarrow> 'b. inj h \<and> surj h"
    22   shows \<open>\<exists>h :: 'a \<Rightarrow> 'b. inj h \<and> surj h\<close>
    23 proof
    23 proof
    24   define A where "A = lfp (\<lambda>X. - (g ` (- (f ` X))))"
    24   define A where \<open>A = lfp (\<lambda>X. - (g ` (- (f ` X))))\<close>
    25   define g' where "g' = inv g"
    25   define g' where \<open>g' = inv g\<close>
    26   let ?h = "\<lambda>z. if z \<in> A then f z else g' z"
    26   let ?h = \<open>\<lambda>z. if z \<in> A then f z else g' z\<close>
    27 
    27 
    28   have "A = - (g ` (- (f ` A)))"
    28   have \<open>A = - (g ` (- (f ` A)))\<close>
    29     unfolding A_def by (rule lfp_unfold) (blast intro: monoI)
    29     unfolding A_def by (rule lfp_unfold) (blast intro: monoI)
    30   then have A_compl: "- A = g ` (- (f ` A))" by blast
    30   then have A_compl: \<open>- A = g ` (- (f ` A))\<close> by blast
    31   then have *: "g' ` (- A) = - (f ` A)"
    31   then have *: \<open>g' ` (- A) = - (f ` A)\<close>
    32     using g'_def \<open>inj g\<close> by auto
    32     using g'_def \<open>inj g\<close> by auto
    33 
    33 
    34   show "inj ?h \<and> surj ?h"
    34   show \<open>inj ?h \<and> surj ?h\<close>
    35   proof
    35   proof
    36     from * show "surj ?h" by auto
    36     from * show \<open>surj ?h\<close> by auto
    37     have "inj_on f A"
    37     have \<open>inj_on f A\<close>
    38       using \<open>inj f\<close> by (rule subset_inj_on) blast
    38       using \<open>inj f\<close> by (rule subset_inj_on) blast
    39     moreover
    39     moreover
    40     have "inj_on g' (- A)"
    40     have \<open>inj_on g' (- A)\<close>
    41       unfolding g'_def
    41       unfolding g'_def
    42     proof (rule inj_on_inv_into)
    42     proof (rule inj_on_inv_into)
    43       have "g ` (- (f ` A)) \<subseteq> range g" by blast
    43       have \<open>g ` (- (f ` A)) \<subseteq> range g\<close> by blast
    44       then show "- A \<subseteq> range g" by (simp only: A_compl)
    44       then show \<open>- A \<subseteq> range g\<close> by (simp only: A_compl)
    45     qed
    45     qed
    46     moreover
    46     moreover
    47     have False if eq: "f a = g' b" and a: "a \<in> A" and b: "b \<in> - A" for a b
    47     have False if eq: \<open>f a = g' b\<close> and a: \<open>a \<in> A\<close> and b: \<open>b \<in> - A\<close> for a b
    48     proof -
    48     proof -
    49       from a have fa: "f a \<in> f ` A" by (rule imageI)
    49       from a have fa: \<open>f a \<in> f ` A\<close> by (rule imageI)
    50       from b have "g' b \<in> g' ` (- A)" by (rule imageI)
    50       from b have \<open>g' b \<in> g' ` (- A)\<close> by (rule imageI)
    51       with * have "g' b \<in> - (f ` A)" by simp
    51       with * have \<open>g' b \<in> - (f ` A)\<close> by simp
    52       with eq fa show False by simp
    52       with eq fa show False by simp
    53     qed
    53     qed
    54     ultimately show "inj ?h"
    54     ultimately show \<open>inj ?h\<close>
    55       unfolding inj_on_def by (metis ComplI)
    55       unfolding inj_on_def by (metis ComplI)
    56   qed
    56   qed
    57 qed
    57 qed
    58 
    58 
    59 end
    59 end