150 proof |
150 proof |
151 fix x :: 'a |
151 fix x :: 'a |
152 from length map_of_zip_enum_is_Some obtain y1 y2 |
152 from length map_of_zip_enum_is_Some obtain y1 y2 |
153 where "map_of (zip (enum \<Colon> 'a list) xs) x = Some y1" |
153 where "map_of (zip (enum \<Colon> 'a list) xs) x = Some y1" |
154 and "map_of (zip (enum \<Colon> 'a list) ys) x = Some y2" by blast |
154 and "map_of (zip (enum \<Colon> 'a list) ys) x = Some y2" by blast |
155 moreover from map_of have "the (map_of (zip (enum \<Colon> 'a\<Colon>enum list) xs) x) = the (map_of (zip (enum \<Colon> 'a\<Colon>enum list) ys) x)" |
155 moreover from map_of |
|
156 have "the (map_of (zip (enum \<Colon> 'a\<Colon>enum list) xs) x) = the (map_of (zip (enum \<Colon> 'a\<Colon>enum list) ys) x)" |
156 by (auto dest: fun_cong) |
157 by (auto dest: fun_cong) |
157 ultimately show "map_of (zip (enum \<Colon> 'a\<Colon>enum list) xs) x = map_of (zip (enum \<Colon> 'a\<Colon>enum list) ys) x" |
158 ultimately show "map_of (zip (enum \<Colon> 'a\<Colon>enum list) xs) x = map_of (zip (enum \<Colon> 'a\<Colon>enum list) ys) x" |
158 by simp |
159 by simp |
159 qed |
160 qed |
160 with length enum_distinct show "xs = ys" by (rule map_of_zip_inject) |
161 with length enum_distinct show "xs = ys" by (rule map_of_zip_inject) |
830 by (auto simp: inj_on_def) (metis linorder_less_linear order_less_imp_not_eq) |
831 by (auto simp: inj_on_def) (metis linorder_less_linear order_less_imp_not_eq) |
831 with `finite (range f)` have "finite (UNIV::nat set)" |
832 with `finite (range f)` have "finite (UNIV::nat set)" |
832 by (rule finite_imageD) |
833 by (rule finite_imageD) |
833 then show False by simp |
834 then show False by simp |
834 qed |
835 qed |
835 then guess n .. note n = this |
836 then obtain n where n: "f n = f (Suc n)" .. |
836 def N \<equiv> "LEAST n. f n = f (Suc n)" |
837 def N \<equiv> "LEAST n. f n = f (Suc n)" |
837 have N: "f N = f (Suc N)" |
838 have N: "f N = f (Suc N)" |
838 unfolding N_def using n by (rule LeastI) |
839 unfolding N_def using n by (rule LeastI) |
839 show ?thesis |
840 show ?thesis |
840 proof (intro exI[of _ N] conjI allI impI) |
841 proof (intro exI[of _ N] conjI allI impI) |
919 assumes "finite r" |
920 assumes "finite r" |
920 shows "acc r \<subseteq> (UN n. bacc r n)" |
921 shows "acc r \<subseteq> (UN n. bacc r n)" |
921 proof |
922 proof |
922 fix x |
923 fix x |
923 assume "x : acc r" |
924 assume "x : acc r" |
924 from this have "\<exists> n. x : bacc r n" |
925 then have "\<exists> n. x : bacc r n" |
925 proof (induct x arbitrary: n rule: acc.induct) |
926 proof (induct x arbitrary: rule: acc.induct) |
926 case (accI x) |
927 case (accI x) |
927 from accI have "\<forall> y. \<exists> n. (y, x) \<in> r --> y : bacc r n" by simp |
928 then have "\<forall>y. \<exists> n. (y, x) \<in> r --> y : bacc r n" by simp |
928 from choice[OF this] guess n .. note n = this |
929 from choice[OF this] obtain n where n: "\<forall>y. (y, x) \<in> r \<longrightarrow> y \<in> bacc r (n y)" .. |
929 have "\<exists> n. \<forall>y. (y, x) : r --> y : bacc r n" |
930 obtain n where "\<And>y. (y, x) : r \<Longrightarrow> y : bacc r n" |
930 proof (safe intro!: exI[of _ "Max ((%(y,x). n y)`r)"]) |
931 proof |
931 fix y assume y: "(y, x) : r" |
932 fix y assume y: "(y, x) : r" |
932 with n have "y : bacc r (n y)" by auto |
933 with n have "y : bacc r (n y)" by auto |
933 moreover have "n y <= Max ((%(y, x). n y) ` r)" |
934 moreover have "n y <= Max ((%(y, x). n y) ` r)" |
934 using y `finite r` by (auto intro!: Max_ge) |
935 using y `finite r` by (auto intro!: Max_ge) |
935 note bacc_mono[OF this, of r] |
936 note bacc_mono[OF this, of r] |
936 ultimately show "y : bacc r (Max ((%(y, x). n y) ` r))" by auto |
937 ultimately show "y : bacc r (Max ((%(y, x). n y) ` r))" by auto |
937 qed |
938 qed |
938 from this guess n .. |
939 then show ?case |
939 from this show ?case |
|
940 by (auto simp add: Let_def intro!: exI[of _ "Suc n"]) |
940 by (auto simp add: Let_def intro!: exI[of _ "Suc n"]) |
941 qed |
941 qed |
942 thus "x : (UN n. bacc r n)" by auto |
942 then show "x : (UN n. bacc r n)" by auto |
943 qed |
943 qed |
944 |
944 |
945 lemma acc_bacc_eq: "acc ((set xs) :: (('a :: enum) * 'a) set) = bacc (set xs) (card (UNIV :: 'a set))" |
945 lemma acc_bacc_eq: "acc ((set xs) :: (('a :: enum) * 'a) set) = bacc (set xs) (card (UNIV :: 'a set))" |
946 by (metis acc_subseteq_bacc bacc_subseteq_acc bacc_upper_bound finite_set order_eq_iff) |
946 by (metis acc_subseteq_bacc bacc_subseteq_acc bacc_upper_bound finite_set order_eq_iff) |
947 |
947 |