equal
deleted
inserted
replaced
18 lemma uniq_choice: "\<forall>x. \<exists>!y. Q x y \<Longrightarrow> \<exists>f. \<forall>x. Q x (f x)" |
18 lemma uniq_choice: "\<forall>x. \<exists>!y. Q x y \<Longrightarrow> \<exists>f. \<forall>x. Q x (f x)" |
19 by (force intro: theI') |
19 by (force intro: theI') |
20 |
20 |
21 lemma b_uniq_choice: "\<forall>x\<in>S. \<exists>!y. Q x y \<Longrightarrow> \<exists>f. \<forall>x\<in>S. Q x (f x)" |
21 lemma b_uniq_choice: "\<forall>x\<in>S. \<exists>!y. Q x y \<Longrightarrow> \<exists>f. \<forall>x\<in>S. Q x (f x)" |
22 by (force intro: theI') |
22 by (force intro: theI') |
|
23 |
23 |
24 |
24 subsection \<open>The Identity Function \<open>id\<close>\<close> |
25 subsection \<open>The Identity Function \<open>id\<close>\<close> |
25 |
26 |
26 definition id :: "'a \<Rightarrow> 'a" |
27 definition id :: "'a \<Rightarrow> 'a" |
27 where "id = (\<lambda>x. x)" |
28 where "id = (\<lambda>x. x)" |
281 lemma linorder_injI: |
282 lemma linorder_injI: |
282 assumes hyp: "\<And>x y::'a::linorder. x < y \<Longrightarrow> f x \<noteq> f y" |
283 assumes hyp: "\<And>x y::'a::linorder. x < y \<Longrightarrow> f x \<noteq> f y" |
283 shows "inj f" |
284 shows "inj f" |
284 \<comment> \<open>Courtesy of Stephan Merz\<close> |
285 \<comment> \<open>Courtesy of Stephan Merz\<close> |
285 proof (rule inj_onI) |
286 proof (rule inj_onI) |
286 fix x y |
287 show "x = y" if "f x = f y" for x y |
287 assume f_eq: "f x = f y" |
288 by (rule linorder_cases) (auto dest: hyp simp: that) |
288 show "x = y" by (rule linorder_cases) (auto dest: hyp simp: f_eq) |
|
289 qed |
289 qed |
290 |
290 |
291 lemma surj_def: "surj f \<longleftrightarrow> (\<forall>y. \<exists>x. y = f x)" |
291 lemma surj_def: "surj f \<longleftrightarrow> (\<forall>y. \<exists>x. y = f x)" |
292 by auto |
292 by auto |
293 |
293 |
425 |
425 |
426 lemma bij_betw_id_iff: "bij_betw id A B \<longleftrightarrow> A = B" |
426 lemma bij_betw_id_iff: "bij_betw id A B \<longleftrightarrow> A = B" |
427 by (auto simp add: bij_betw_def) |
427 by (auto simp add: bij_betw_def) |
428 |
428 |
429 lemma bij_betw_combine: |
429 lemma bij_betw_combine: |
430 assumes "bij_betw f A B" "bij_betw f C D" "B \<inter> D = {}" |
430 "bij_betw f A B \<Longrightarrow> bij_betw f C D \<Longrightarrow> B \<inter> D = {} \<Longrightarrow> bij_betw f (A \<union> C) (B \<union> D)" |
431 shows "bij_betw f (A \<union> C) (B \<union> D)" |
431 unfolding bij_betw_def inj_on_Un image_Un by auto |
432 using assms unfolding bij_betw_def inj_on_Un image_Un by auto |
|
433 |
432 |
434 lemma bij_betw_subset: "bij_betw f A A' \<Longrightarrow> B \<le> A \<Longrightarrow> f ` B = B' \<Longrightarrow> bij_betw f B B'" |
433 lemma bij_betw_subset: "bij_betw f A A' \<Longrightarrow> B \<le> A \<Longrightarrow> f ` B = B' \<Longrightarrow> bij_betw f B B'" |
435 by (auto simp add: bij_betw_def inj_on_def) |
434 by (auto simp add: bij_betw_def inj_on_def) |
436 |
435 |
437 lemma bij_pointE: |
436 lemma bij_pointE: |
529 and right: "\<forall>a' \<in> A'. f (f' a') = a'" |
528 and right: "\<forall>a' \<in> A'. f (f' a') = a'" |
530 and "f ` A \<le> A'" |
529 and "f ` A \<le> A'" |
531 and img2: "f' ` A' \<le> A" |
530 and img2: "f' ` A' \<le> A" |
532 shows "bij_betw f A A'" |
531 shows "bij_betw f A A'" |
533 using assms |
532 using assms |
534 proof (unfold bij_betw_def inj_on_def, safe) |
533 unfolding bij_betw_def inj_on_def |
|
534 proof safe |
535 fix a b |
535 fix a b |
536 assume *: "a \<in> A" "b \<in> A" and **: "f a = f b" |
536 assume *: "a \<in> A" "b \<in> A" and **: "f a = f b" |
537 have "a = f' (f a) \<and> b = f'(f b)" using * left by simp |
537 have "a = f' (f a) \<and> b = f'(f b)" using * left by simp |
538 with ** show "a = b" by simp |
538 with ** show "a = b" by simp |
539 next |
539 next |
540 fix a' assume *: "a' \<in> A'" |
540 fix a' assume *: "a' \<in> A'" |
541 hence "f' a' \<in> A" using img2 by blast |
541 then have "f' a' \<in> A" using img2 by blast |
542 moreover |
542 moreover |
543 have "a' = f (f' a')" using * right by simp |
543 have "a' = f (f' a')" using * right by simp |
544 ultimately show "a' \<in> f ` A" by blast |
544 ultimately show "a' \<in> f ` A" by blast |
545 qed |
545 qed |
546 |
546 |
821 |
821 |
822 subsection \<open>Setup\<close> |
822 subsection \<open>Setup\<close> |
823 |
823 |
824 subsubsection \<open>Proof tools\<close> |
824 subsubsection \<open>Proof tools\<close> |
825 |
825 |
826 text \<open>Simplify terms of the form f(...,x:=y,...,x:=z,...) to f(...,x:=z,...)\<close> |
826 text \<open>Simplify terms of the form \<open>f(\<dots>,x:=y,\<dots>,x:=z,\<dots>)\<close> to \<open>f(\<dots>,x:=z,\<dots>)\<close>\<close> |
827 |
827 |
828 simproc_setup fun_upd2 ("f(v := w, x := y)") = \<open>fn _ => |
828 simproc_setup fun_upd2 ("f(v := w, x := y)") = \<open>fn _ => |
829 let |
829 let |
830 fun gen_fun_upd NONE T _ _ = NONE |
830 fun gen_fun_upd NONE T _ _ = NONE |
831 | gen_fun_upd (SOME f) T x y = SOME (Const (@{const_name fun_upd}, T) $ f $ x $ y) |
831 | gen_fun_upd (SOME f) T x y = SOME (Const (@{const_name fun_upd}, T) $ f $ x $ y) |
841 |
841 |
842 fun proc ctxt ct = |
842 fun proc ctxt ct = |
843 let |
843 let |
844 val t = Thm.term_of ct |
844 val t = Thm.term_of ct |
845 in |
845 in |
846 case find_double t of |
846 (case find_double t of |
847 (T, NONE) => NONE |
847 (T, NONE) => NONE |
848 | (T, SOME rhs) => |
848 | (T, SOME rhs) => |
849 SOME (Goal.prove ctxt [] [] (Logic.mk_equals (t, rhs)) |
849 SOME (Goal.prove ctxt [] [] (Logic.mk_equals (t, rhs)) |
850 (fn _ => |
850 (fn _ => |
851 resolve_tac ctxt [eq_reflection] 1 THEN |
851 resolve_tac ctxt [eq_reflection] 1 THEN |
852 resolve_tac ctxt @{thms ext} 1 THEN |
852 resolve_tac ctxt @{thms ext} 1 THEN |
853 simp_tac (put_simpset ss ctxt) 1)) |
853 simp_tac (put_simpset ss ctxt) 1))) |
854 end |
854 end |
855 in proc end |
855 in proc end |
856 \<close> |
856 \<close> |
857 |
857 |
858 |
858 |