src/HOL/Fun.thy
changeset 63416 6af79184bef3
parent 63400 249fa34faba2
child 63561 fba08009ff3e
equal deleted inserted replaced
63415:8f91c2f447a0 63416:6af79184bef3
   148 text \<open>A common special case: functions injective, surjective or bijective over
   148 text \<open>A common special case: functions injective, surjective or bijective over
   149   the entire domain type.\<close>
   149   the entire domain type.\<close>
   150 
   150 
   151 abbreviation "inj f \<equiv> inj_on f UNIV"
   151 abbreviation "inj f \<equiv> inj_on f UNIV"
   152 
   152 
   153 abbreviation surj :: "('a \<Rightarrow> 'b) \<Rightarrow> bool"  \<comment> "surjective"
   153 abbreviation (input) surj :: "('a \<Rightarrow> 'b) \<Rightarrow> bool"
   154   where "surj f \<equiv> range f = UNIV"
   154   where "surj f \<equiv> range f = UNIV"
   155 
   155 
   156 abbreviation "bij f \<equiv> bij_betw f UNIV UNIV"
   156 abbreviation "bij f \<equiv> bij_betw f UNIV UNIV"
   157 
       
   158 text \<open>The negated case:\<close>
       
   159 translations
       
   160   "\<not> CONST surj f" \<leftharpoondown> "CONST range f \<noteq> CONST UNIV"
       
   161 
   157 
   162 lemma injI: "(\<And>x y. f x = f y \<Longrightarrow> x = y) \<Longrightarrow> inj f"
   158 lemma injI: "(\<And>x y. f x = f y \<Longrightarrow> x = y) \<Longrightarrow> inj f"
   163   unfolding inj_on_def by auto
   159   unfolding inj_on_def by auto
   164 
   160 
   165 theorem range_ex1_eq: "inj f \<Longrightarrow> b \<in> range f \<longleftrightarrow> (\<exists>!x. b = f x)"
   161 theorem range_ex1_eq: "inj f \<Longrightarrow> b \<in> range f \<longleftrightarrow> (\<exists>!x. b = f x)"
   301 
   297 
   302 lemma surjE: "surj f \<Longrightarrow> (\<And>x. y = f x \<Longrightarrow> C) \<Longrightarrow> C"
   298 lemma surjE: "surj f \<Longrightarrow> (\<And>x. y = f x \<Longrightarrow> C) \<Longrightarrow> C"
   303   by (simp add: surj_def, blast)
   299   by (simp add: surj_def, blast)
   304 
   300 
   305 lemma comp_surj: "surj f \<Longrightarrow> surj g \<Longrightarrow> surj (g \<circ> f)"
   301 lemma comp_surj: "surj f \<Longrightarrow> surj g \<Longrightarrow> surj (g \<circ> f)"
   306   apply (simp add: comp_def surj_def)
   302   by (simp add: image_comp [symmetric])
   307   apply clarify
       
   308   apply (drule_tac x = y in spec)
       
   309   apply clarify
       
   310   apply (drule_tac x = x in spec)
       
   311   apply blast
       
   312   done
       
   313 
   303 
   314 lemma bij_betw_imageI: "inj_on f A \<Longrightarrow> f ` A = B \<Longrightarrow> bij_betw f A B"
   304 lemma bij_betw_imageI: "inj_on f A \<Longrightarrow> f ` A = B \<Longrightarrow> bij_betw f A B"
   315   unfolding bij_betw_def by clarify
   305   unfolding bij_betw_def by clarify
   316 
   306 
   317 lemma bij_betw_imp_surj_on: "bij_betw f A B \<Longrightarrow> f ` A = B"
   307 lemma bij_betw_imp_surj_on: "bij_betw f A B \<Longrightarrow> f ` A = B"