src/HOL/Fun.thy
changeset 34209 c7f621786035
parent 34153 5da0f7abbe29
child 35115 446c5063e4fd
equal deleted inserted replaced
34208:a7acd6c68d9b 34209:c7f621786035
   169 
   169 
   170 lemma surj_id[simp]: "surj id"
   170 lemma surj_id[simp]: "surj id"
   171 by (simp add: surj_def) 
   171 by (simp add: surj_def) 
   172 
   172 
   173 lemma bij_id[simp]: "bij id"
   173 lemma bij_id[simp]: "bij id"
   174 by (simp add: bij_def inj_on_id surj_id) 
   174 by (simp add: bij_def)
   175 
   175 
   176 lemma inj_onI:
   176 lemma inj_onI:
   177     "(!! x y. [|  x:A;  y:A;  f(x) = f(y) |] ==> x=y) ==> inj_on f A"
   177     "(!! x y. [|  x:A;  y:A;  f(x) = f(y) |] ==> x=y) ==> inj_on f A"
   178 by (simp add: inj_on_def)
   178 by (simp add: inj_on_def)
   179 
   179 
   430 
   430 
   431 lemma fun_upd_twist: "a ~= c ==> (m(a:=b))(c:=d) = (m(c:=d))(a:=b)"
   431 lemma fun_upd_twist: "a ~= c ==> (m(a:=b))(c:=d) = (m(c:=d))(a:=b)"
   432 by (rule ext, auto)
   432 by (rule ext, auto)
   433 
   433 
   434 lemma inj_on_fun_updI: "\<lbrakk> inj_on f A; y \<notin> f`A \<rbrakk> \<Longrightarrow> inj_on (f(x:=y)) A"
   434 lemma inj_on_fun_updI: "\<lbrakk> inj_on f A; y \<notin> f`A \<rbrakk> \<Longrightarrow> inj_on (f(x:=y)) A"
   435 by(fastsimp simp:inj_on_def image_def)
   435 by (fastsimp simp:inj_on_def image_def)
   436 
   436 
   437 lemma fun_upd_image:
   437 lemma fun_upd_image:
   438      "f(x:=y) ` A = (if x \<in> A then insert y (f ` (A-{x})) else f ` A)"
   438      "f(x:=y) ` A = (if x \<in> A then insert y (f ` (A-{x})) else f ` A)"
   439 by auto
   439 by auto
   440 
   440 
   441 lemma fun_upd_comp: "f \<circ> (g(x := y)) = (f \<circ> g)(x := f y)"
   441 lemma fun_upd_comp: "f \<circ> (g(x := y)) = (f \<circ> g)(x := f y)"
   442 by(auto intro: ext)
   442 by (auto intro: ext)
   443 
   443 
   444 
   444 
   445 subsection {* @{text override_on} *}
   445 subsection {* @{text override_on} *}
   446 
   446 
   447 definition
   447 definition
   494   with A have "inj_on (swap a b (swap a b f)) A" 
   494   with A have "inj_on (swap a b (swap a b f)) A" 
   495     by (iprover intro: inj_on_imp_inj_on_swap) 
   495     by (iprover intro: inj_on_imp_inj_on_swap) 
   496   thus "inj_on f A" by simp 
   496   thus "inj_on f A" by simp 
   497 next
   497 next
   498   assume "inj_on f A"
   498   assume "inj_on f A"
   499   with A show "inj_on (swap a b f) A" by(iprover intro: inj_on_imp_inj_on_swap)
   499   with A show "inj_on (swap a b f) A" by (iprover intro: inj_on_imp_inj_on_swap)
   500 qed
   500 qed
   501 
   501 
   502 lemma surj_imp_surj_swap: "surj f ==> surj (swap a b f)"
   502 lemma surj_imp_surj_swap: "surj f ==> surj (swap a b f)"
   503 apply (simp add: surj_def swap_def, clarify)
   503 apply (simp add: surj_def swap_def, clarify)
   504 apply (case_tac "y = f b", blast)
   504 apply (case_tac "y = f b", blast)
   527 "the_inv_into A f == %x. THE y. y : A & f y = x"
   527 "the_inv_into A f == %x. THE y. y : A & f y = x"
   528 
   528 
   529 lemma the_inv_into_f_f:
   529 lemma the_inv_into_f_f:
   530   "[| inj_on f A;  x : A |] ==> the_inv_into A f (f x) = x"
   530   "[| inj_on f A;  x : A |] ==> the_inv_into A f (f x) = x"
   531 apply (simp add: the_inv_into_def inj_on_def)
   531 apply (simp add: the_inv_into_def inj_on_def)
   532 apply (blast intro: the_equality)
   532 apply blast
   533 done
   533 done
   534 
   534 
   535 lemma f_the_inv_into_f:
   535 lemma f_the_inv_into_f:
   536   "inj_on f A ==> y : f`A  ==> f (the_inv_into A f y) = y"
   536   "inj_on f A ==> y : f`A  ==> f (the_inv_into A f y) = y"
   537 apply (simp add: the_inv_into_def)
   537 apply (simp add: the_inv_into_def)