| 61938 |      1 | (*  Title:      HOL/Isar_Examples/Schroeder_Bernstein.thy
 | 
|  |      2 |     Author:     Makarius
 | 
|  |      3 | *)
 | 
|  |      4 | 
 | 
|  |      5 | section \<open>Schröder-Bernstein Theorem\<close>
 | 
|  |      6 | 
 | 
|  |      7 | theory Schroeder_Bernstein
 | 
|  |      8 | imports Main
 | 
|  |      9 | begin
 | 
|  |     10 | 
 | 
|  |     11 | text \<open>
 | 
|  |     12 |   See also:
 | 
| 61939 |     13 |   \<^item> @{file "$ISABELLE_HOME/src/HOL/ex/Set_Theory.thy"}
 | 
| 61938 |     14 |   \<^item> @{url "http://planetmath.org/proofofschroederbernsteintheoremusingtarskiknastertheorem"}
 | 
|  |     15 |   \<^item> Springer LNCS 828 (cover page)
 | 
|  |     16 | \<close>
 | 
|  |     17 | 
 | 
|  |     18 | theorem Schroeder_Bernstein:
 | 
|  |     19 |   fixes f :: "'a \<Rightarrow> 'b"
 | 
|  |     20 |     and g :: "'b \<Rightarrow> 'a"
 | 
|  |     21 |   assumes "inj f" and "inj g"
 | 
|  |     22 |   shows "\<exists>h :: 'a \<Rightarrow> 'b. inj h \<and> surj h"
 | 
|  |     23 | proof
 | 
|  |     24 |   def A \<equiv> "lfp (\<lambda>X. - (g ` (- (f ` X))))"
 | 
|  |     25 |   def g' \<equiv> "inv g"
 | 
|  |     26 |   let ?h = "\<lambda>z. if z \<in> A then f z else g' z"
 | 
|  |     27 | 
 | 
|  |     28 |   have "A = - (g ` (- (f ` A)))"
 | 
|  |     29 |     unfolding A_def by (rule lfp_unfold) (blast intro: monoI)
 | 
|  |     30 |   then have A_compl: "- A = g ` (- (f ` A))" by blast
 | 
|  |     31 |   then have *: "g' ` (- A) = - (f ` A)"
 | 
|  |     32 |     using g'_def \<open>inj g\<close> by auto
 | 
|  |     33 | 
 | 
|  |     34 |   show "inj ?h \<and> surj ?h"
 | 
|  |     35 |   proof
 | 
|  |     36 |     from * show "surj ?h" by auto
 | 
|  |     37 |     have "inj_on f A"
 | 
|  |     38 |       using \<open>inj f\<close> by (rule subset_inj_on) blast
 | 
|  |     39 |     moreover
 | 
|  |     40 |     have "inj_on g' (- A)"
 | 
|  |     41 |       unfolding g'_def
 | 
|  |     42 |     proof (rule inj_on_inv_into)
 | 
|  |     43 |       have "g ` (- (f ` A)) \<subseteq> range g" by blast
 | 
|  |     44 |       then show "- A \<subseteq> range g" by (simp only: A_compl)
 | 
|  |     45 |     qed
 | 
|  |     46 |     moreover
 | 
|  |     47 |     have False if eq: "f a = g' b" and a: "a \<in> A" and b: "b \<in> - A" for a b
 | 
|  |     48 |     proof -
 | 
|  |     49 |       from a have fa: "f a \<in> f ` A" by (rule imageI)
 | 
|  |     50 |       from b have "g' b \<in> g' ` (- A)" by (rule imageI)
 | 
|  |     51 |       with * have "g' b \<in> - (f ` A)" by simp
 | 
|  |     52 |       with eq fa show False by simp
 | 
|  |     53 |     qed
 | 
|  |     54 |     ultimately show "inj ?h"
 | 
|  |     55 |       unfolding inj_on_def by (metis ComplI)
 | 
|  |     56 |   qed
 | 
|  |     57 | qed
 | 
|  |     58 | 
 | 
|  |     59 | end
 |