# HG changeset patch # User wenzelm # Date 1474225584 -7200 # Node ID 5e816da75b8f87731ba40c18fc5cf1eb3f49192c # Parent 255294779d401332a9ee55df0c09d1a4692a82e7# Parent bab633745c7fd4dbf6eafc66a3d886f5c1618735 merged diff -r 255294779d40 -r 5e816da75b8f src/HOL/Deriv.thy --- a/src/HOL/Deriv.thy Sun Sep 18 18:36:37 2016 +0200 +++ b/src/HOL/Deriv.thy Sun Sep 18 21:06:24 2016 +0200 @@ -119,16 +119,9 @@ qed (blast intro: bounded_linear_add f g has_derivative_bounded_linear) lemma has_derivative_setsum[simp, derivative_intros]: - assumes f: "\i. i \ I \ (f i has_derivative f' i) F" - shows "((\x. \i\I. f i x) has_derivative (\x. \i\I. f' i x)) F" -proof (cases "finite I") - case True - from this f show ?thesis - by induct (simp_all add: f) -next - case False - then show ?thesis by simp -qed + "(\i. i \ I \ (f i has_derivative f' i) F) \ + ((\x. \i\I. f i x) has_derivative (\x. \i\I. f' i x)) F" + by (induct I rule: infinite_finite_induct) simp_all lemma has_derivative_minus[simp, derivative_intros]: "(f has_derivative f') F \ ((\x. - f x) has_derivative (\x. - f' x)) F" @@ -360,28 +353,24 @@ lemma has_derivative_setprod[simp, derivative_intros]: fixes f :: "'i \ 'a::real_normed_vector \ 'b::real_normed_field" - assumes f: "\i. i \ I \ (f i has_derivative f' i) (at x within s)" - shows "((\x. \i\I. f i x) has_derivative (\y. \i\I. f' i y * (\j\I - {i}. f j x))) (at x within s)" -proof (cases "finite I") - case True - from this f show ?thesis - proof induct - case empty - then show ?case by simp - next - case (insert i I) - let ?P = "\y. f i x * (\i\I. f' i y * (\j\I - {i}. f j x)) + (f' i y) * (\i\I. f i x)" - have "((\x. f i x * (\i\I. f i x)) has_derivative ?P) (at x within s)" - using insert by (intro has_derivative_mult) auto - also have "?P = (\y. \i'\insert i I. f' i' y * (\j\insert i I - {i'}. f j x))" - using insert(1,2) - by (auto simp add: setsum_right_distrib insert_Diff_if intro!: ext setsum.cong) - finally show ?case - using insert by simp - qed + shows "(\i. i \ I \ (f i has_derivative f' i) (at x within s)) \ + ((\x. \i\I. f i x) has_derivative (\y. \i\I. f' i y * (\j\I - {i}. f j x))) (at x within s)" +proof (induct I rule: infinite_finite_induct) + case infinite + then show ?case by simp +next + case empty + then show ?case by simp next - case False - then show ?thesis by simp + case (insert i I) + let ?P = "\y. f i x * (\i\I. f' i y * (\j\I - {i}. f j x)) + (f' i y) * (\i\I. f i x)" + have "((\x. f i x * (\i\I. f i x)) has_derivative ?P) (at x within s)" + using insert by (intro has_derivative_mult) auto + also have "?P = (\y. \i'\insert i I. f' i' y * (\j\insert i I - {i'}. f j x))" + using insert(1,2) + by (auto simp add: setsum_right_distrib insert_Diff_if intro!: ext setsum.cong) + finally show ?case + using insert by simp qed lemma has_derivative_power[simp, derivative_intros]: diff -r 255294779d40 -r 5e816da75b8f src/HOL/Finite_Set.thy --- a/src/HOL/Finite_Set.thy Sun Sep 18 18:36:37 2016 +0200 +++ b/src/HOL/Finite_Set.thy Sun Sep 18 21:06:24 2016 +0200 @@ -610,26 +610,22 @@ and empty: "P {}" and insert: "\a F. \finite F; a \ A; F \ A; a \ F; P F \ \ P (insert a F)" shows "P F" -proof - - from \finite F\ - have "F \ A \ ?thesis" - proof induct - show "P {}" by fact - next - fix x F - assume "finite F" and "x \ F" and - P: "F \ A \ P F" and i: "insert x F \ A" - show "P (insert x F)" - proof (rule insert) - from i show "x \ A" by blast - from i have "F \ A" by blast - with P show "P F" . - show "finite F" by fact - show "x \ F" by fact - show "F \ A" by fact - qed + using assms(1,2) +proof induct + show "P {}" by fact +next + fix x F + assume "finite F" and "x \ F" and + P: "F \ A \ P F" and i: "insert x F \ A" + show "P (insert x F)" + proof (rule insert) + from i show "x \ A" by blast + from i have "F \ A" by blast + with P show "P F" . + show "finite F" by fact + show "x \ F" by fact + show "F \ A" by fact qed - with \F \ A\ show ?thesis by blast qed @@ -1442,6 +1438,7 @@ assumes "finite B" and "B \ A" shows "card (A - B) = card A - card B" + using assms proof (cases "finite A") case False with assms show ?thesis @@ -1752,20 +1749,12 @@ lemma card_image_le: "finite A \ card (f ` A) \ card A" by (induct rule: finite_induct) (simp_all add: le_SucI card_insert_if) -lemma card_image: - assumes "inj_on f A" - shows "card (f ` A) = card A" -proof (cases "finite A") - case True - then show ?thesis - using assms by (induct A) simp_all -next - case False - then have "\ finite (f ` A)" - using assms by (auto dest: finite_imageD) - with False show ?thesis - by simp -qed +lemma card_image: "inj_on f A \ card (f ` A) = card A" +proof (induct A rule: infinite_finite_induct) + case (infinite A) + then have "\ finite (f ` A)" by (auto dest: finite_imageD) + with infinite show ?case by simp +qed simp_all lemma bij_betw_same_card: "bij_betw f A B \ card A = card B" by (auto simp: card_image bij_betw_def) diff -r 255294779d40 -r 5e816da75b8f src/HOL/GCD.thy --- a/src/HOL/GCD.thy Sun Sep 18 18:36:37 2016 +0200 +++ b/src/HOL/GCD.thy Sun Sep 18 21:06:24 2016 +0200 @@ -860,10 +860,7 @@ by (subst add_commute) simp lemma setprod_coprime [rule_format]: "(\i\A. gcd (f i) a = 1) \ gcd (\i\A. f i) a = 1" - apply (cases "finite A") - apply (induct set: finite) - apply (auto simp add: gcd_mult_cancel) - done + by (induct A rule: infinite_finite_induct) (auto simp add: gcd_mult_cancel) lemma prod_list_coprime: "(\x. x \ set xs \ coprime x y) \ coprime (prod_list xs) y" by (induct xs) (simp_all add: gcd_mult_cancel) diff -r 255294779d40 -r 5e816da75b8f src/HOL/Groups_Big.thy --- a/src/HOL/Groups_Big.thy Sun Sep 18 18:36:37 2016 +0200 +++ b/src/HOL/Groups_Big.thy Sun Sep 18 21:06:24 2016 +0200 @@ -570,22 +570,8 @@ qed lemma (in ordered_comm_monoid_add) setsum_mono: - assumes le: "\i. i\K \ f i \ g i" - shows "(\i\K. f i) \ (\i\K. g i)" -proof (cases "finite K") - case True - from this le show ?thesis - proof induct - case empty - then show ?case by simp - next - case insert - then show ?case using add_mono by fastforce - qed -next - case False - then show ?thesis by simp -qed + "(\i. i\K \ f i \ g i) \ (\i\K. f i) \ (\i\K. g i)" + by (induct K rule: infinite_finite_induct) (use add_mono in auto) lemma (in strict_ordered_comm_monoid_add) setsum_strict_mono: assumes "finite A" "A \ {}" @@ -640,13 +626,7 @@ lemma setsum_negf: "(\x\A. - f x) = - (\x\A. f x)" for f :: "'b \ 'a::ab_group_add" -proof (cases "finite A") - case True - then show ?thesis by (induct set: finite) auto -next - case False - then show ?thesis by simp -qed + by (induct A rule: infinite_finite_induct) auto lemma setsum_subtractf: "(\x\A. f x - g x) = (\x\A. f x) - (\x\A. g x)" for f g :: "'b \'a::ab_group_add" @@ -660,43 +640,30 @@ context ordered_comm_monoid_add begin -lemma setsum_nonneg: - assumes nn: "\x\A. 0 \ f x" - shows "0 \ setsum f A" -proof (cases "finite A") - case True - then show ?thesis - using nn - proof induct - case empty - then show ?case by simp - next - case (insert x F) - then have "0 + 0 \ f x + setsum f F" by (blast intro: add_mono) - with insert show ?case by simp - qed +lemma setsum_nonneg: "\x\A. 0 \ f x \ 0 \ setsum f A" +proof (induct A rule: infinite_finite_induct) + case infinite + then show ?case by simp next - case False - then show ?thesis by simp + case empty + then show ?case by simp +next + case (insert x F) + then have "0 + 0 \ f x + setsum f F" by (blast intro: add_mono) + with insert show ?case by simp qed -lemma setsum_nonpos: - assumes np: "\x\A. f x \ 0" - shows "setsum f A \ 0" -proof (cases "finite A") - case True - then show ?thesis - using np - proof induct - case empty - then show ?case by simp - next - case (insert x F) - then have "f x + setsum f F \ 0 + 0" by (blast intro: add_mono) - with insert show ?case by simp - qed +lemma setsum_nonpos: "\x\A. f x \ 0 \ setsum f A \ 0" +proof (induct A rule: infinite_finite_induct) + case infinite + then show ?case by simp next - case False thus ?thesis by simp + case empty + then show ?case by simp +next + case (insert x F) + then have "f x + setsum f F \ 0 + 0" by (blast intro: add_mono) + with insert show ?case by simp qed lemma setsum_nonneg_eq_0_iff: @@ -762,73 +729,56 @@ "finite F \ (setsum f F = 0) = (\a\F. f a = 0)" by (intro ballI setsum_nonneg_eq_0_iff zero_le) -lemma setsum_right_distrib: - fixes f :: "'a \ 'b::semiring_0" - shows "r * setsum f A = setsum (\n. r * f n) A" -proof (cases "finite A") - case True - then show ?thesis - proof induct - case empty - then show ?case by simp - next - case insert - then show ?case by (simp add: distrib_left) - qed +lemma setsum_right_distrib: "r * setsum f A = setsum (\n. r * f n) A" + for f :: "'a \ 'b::semiring_0" +proof (induct A rule: infinite_finite_induct) + case infinite + then show ?case by simp next - case False - then show ?thesis by simp + case empty + then show ?case by simp +next + case insert + then show ?case by (simp add: distrib_left) qed lemma setsum_left_distrib: "setsum f A * r = (\n\A. f n * r)" for r :: "'a::semiring_0" -proof (cases "finite A") - case True - then show ?thesis - proof induct - case empty - then show ?case by simp - next - case insert - then show ?case by (simp add: distrib_right) - qed +proof (induct A rule: infinite_finite_induct) + case infinite + then show ?case by simp next - case False - then show ?thesis by simp + case empty + then show ?case by simp +next + case insert + then show ?case by (simp add: distrib_right) qed lemma setsum_divide_distrib: "setsum f A / r = (\n\A. f n / r)" for r :: "'a::field" -proof (cases "finite A") - case True - then show ?thesis - proof induct - case empty - then show ?case by simp - next - case insert - then show ?case by (simp add: add_divide_distrib) - qed +proof (induct A rule: infinite_finite_induct) + case infinite + then show ?case by simp next - case False - then show ?thesis by simp + case empty + then show ?case by simp +next + case insert + then show ?case by (simp add: add_divide_distrib) qed lemma setsum_abs[iff]: "\setsum f A\ \ setsum (\i. \f i\) A" for f :: "'a \ 'b::ordered_ab_group_add_abs" -proof (cases "finite A") - case True - then show ?thesis - proof induct - case empty - then show ?case by simp - next - case insert - then show ?case by (auto intro: abs_triangle_ineq order_trans) - qed +proof (induct A rule: infinite_finite_induct) + case infinite + then show ?case by simp next - case False - then show ?thesis by simp + case empty + then show ?case by simp +next + case insert + then show ?case by (auto intro: abs_triangle_ineq order_trans) qed lemma setsum_abs_ge_zero[iff]: "0 \ setsum (\i. \f i\) A" @@ -837,23 +787,19 @@ lemma abs_setsum_abs[simp]: "\\a\A. \f a\\ = (\a\A. \f a\)" for f :: "'a \ 'b::ordered_ab_group_add_abs" -proof (cases "finite A") - case True - then show ?thesis - proof induct - case empty - then show ?case by simp - next - case (insert a A) - then have "\\a\insert a A. \f a\\ = \\f a\ + (\a\A. \f a\)\" by simp - also from insert have "\ = \\f a\ + \\a\A. \f a\\\" by simp - also have "\ = \f a\ + \\a\A. \f a\\" by (simp del: abs_of_nonneg) - also from insert have "\ = (\a\insert a A. \f a\)" by simp - finally show ?case . - qed +proof (induct A rule: infinite_finite_induct) + case infinite + then show ?case by simp +next + case empty + then show ?case by simp next - case False - then show ?thesis by simp + case (insert a A) + then have "\\a\insert a A. \f a\\ = \\f a\ + (\a\A. \f a\)\" by simp + also from insert have "\ = \\f a\ + \\a\A. \f a\\\" by simp + also have "\ = \f a\ + \\a\A. \f a\\" by (simp del: abs_of_nonneg) + also from insert have "\ = (\a\insert a A. \f a\)" by simp + finally show ?case . qed lemma setsum_diff1_ring: @@ -873,21 +819,12 @@ setsum f A * setsum g B = setsum id {f a * g b |a b. a \ A \ b \ B}" by(auto simp: setsum_product setsum.cartesian_product intro!: setsum.reindex_cong[symmetric]) -lemma setsum_SucD: - assumes "setsum f A = Suc n" - shows "\a\A. 0 < f a" -proof (cases "finite A") - case True - from this assms show ?thesis by induct auto -next - case False - with assms show ?thesis by simp -qed +lemma setsum_SucD: "setsum f A = Suc n \ \a\A. 0 < f a" + by (induct A rule: infinite_finite_induct) auto lemma setsum_eq_Suc0_iff: - assumes "finite A" - shows "setsum f A = Suc 0 \ (\a\A. f a = Suc 0 \ (\b\A. a \ b \ f b = 0))" - using assms by induct (auto simp add:add_is_1) + "finite A \ setsum f A = Suc 0 \ (\a\A. f a = Suc 0 \ (\b\A. a \ b \ f b = 0))" + by (induct A rule: finite_induct) (auto simp add: add_is_1) lemmas setsum_eq_1_iff = setsum_eq_Suc0_iff[simplified One_nat_def[symmetric]] @@ -899,17 +836,19 @@ lemma setsum_diff1_nat: "setsum f (A - {a}) = (if a \ A then setsum f A - f a else setsum f A)" for f :: "'a \ nat" -proof (cases "finite A") - case True - then show ?thesis - apply induct - apply (auto simp: insert_Diff_if) +proof (induct A rule: infinite_finite_induct) + case infinite + then show ?case by simp +next + case empty + then show ?case by simp +next + case insert + then show ?case + apply (auto simp: insert_Diff_if) apply (drule mk_disjoint_insert) apply auto done -next - case False - then show ?thesis by simp qed lemma setsum_diff_nat: @@ -941,15 +880,8 @@ qed lemma setsum_comp_morphism: - assumes "h 0 = 0" and "\x y. h (x + y) = h x + h y" - shows "setsum (h \ g) A = h (setsum g A)" -proof (cases "finite A") - case False - then show ?thesis by (simp add: assms) -next - case True - then show ?thesis by (induct A) (simp_all add: assms) -qed + "h 0 = 0 \ (\x y. h (x + y) = h x + h y) \ setsum (h \ g) A = h (setsum g A)" + by (induct A rule: infinite_finite_induct) simp_all lemma (in comm_semiring_1) dvd_setsum: "(\a. a \ A \ d dvd f a) \ d dvd setsum f A" by (induct A rule: infinite_finite_induct) simp_all @@ -995,13 +927,7 @@ qed lemma setsum_constant [simp]: "(\x \ A. y) = of_nat (card A) * y" -proof (cases "finite A") - case True - then show ?thesis by induct (auto simp: algebra_simps) -next - case False - then show ?thesis by simp -qed + by (induct A rule: infinite_finite_induct) (auto simp: algebra_simps) lemma setsum_Suc: "setsum (\x. Suc(f x)) A = setsum f A + card A" using setsum.distrib[of f "\_. 1" A] by simp @@ -1033,7 +959,7 @@ proof (cases "finite A") case True then show ?thesis - using le setsum_mono[where K=A and f = "%x. K"] by simp + using le setsum_mono[where K=A and f = "\x. K"] by simp next case False then show ?thesis by simp diff -r 255294779d40 -r 5e816da75b8f src/HOL/Lattices_Big.thy --- a/src/HOL/Lattices_Big.thy Sun Sep 18 18:36:37 2016 +0200 +++ b/src/HOL/Lattices_Big.thy Sun Sep 18 21:06:24 2016 +0200 @@ -522,9 +522,11 @@ assumes "finite A" and min: "\b. b \ A \ a \ b" shows "Min (insert a A) = a" proof (cases "A = {}") - case True then show ?thesis by simp + case True + then show ?thesis by simp next - case False with \finite A\ have "Min (insert a A) = min a (Min A)" + case False + with \finite A\ have "Min (insert a A) = min a (Min A)" by simp moreover from \finite A\ \A \ {}\ min have "a \ Min A" by simp ultimately show ?thesis by (simp add: min.absorb1) @@ -534,9 +536,11 @@ assumes "finite A" and max: "\b. b \ A \ b \ a" shows "Max (insert a A) = a" proof (cases "A = {}") - case True then show ?thesis by simp + case True + then show ?thesis by simp next - case False with \finite A\ have "Max (insert a A) = max a (Max A)" + case False + with \finite A\ have "Max (insert a A) = max a (Max A)" by simp moreover from \finite A\ \A \ {}\ max have "Max A \ a" by simp ultimately show ?thesis by (simp add: max.absorb1) diff -r 255294779d40 -r 5e816da75b8f src/HOL/Limits.thy --- a/src/HOL/Limits.thy Sun Sep 18 18:36:37 2016 +0200 +++ b/src/HOL/Limits.thy Sun Sep 18 21:06:24 2016 +0200 @@ -643,17 +643,8 @@ lemma tendsto_setsum [tendsto_intros]: fixes f :: "'a \ 'b \ 'c::topological_comm_monoid_add" - assumes "\i. i \ I \ (f i \ a i) F" - shows "((\x. \i\I. f i x) \ (\i\I. a i)) F" -proof (cases "finite I") - case True - then show ?thesis - using assms by induct (simp_all add: tendsto_add) -next - case False - then show ?thesis - by simp -qed + shows "(\i. i \ I \ (f i \ a i) F) \ ((\x. \i\I. f i x) \ (\i\I. a i)) F" + by (induct I rule: infinite_finite_induct) (simp_all add: tendsto_add) lemma continuous_setsum [continuous_intros]: fixes f :: "'a \ 'b::t2_space \ 'c::topological_comm_monoid_add" @@ -844,16 +835,8 @@ lemma tendsto_setprod [tendsto_intros]: fixes f :: "'a \ 'b \ 'c::{real_normed_algebra,comm_ring_1}" - assumes "\i. i \ S \ (f i \ L i) F" - shows "((\x. \i\S. f i x) \ (\i\S. L i)) F" -proof (cases "finite S") - case True - then show ?thesis using assms - by induct (simp_all add: tendsto_mult) -next - case False - then show ?thesis by simp -qed + shows "(\i. i \ S \ (f i \ L i) F) \ ((\x. \i\S. f i x) \ (\i\S. L i)) F" + by (induct S rule: infinite_finite_induct) (simp_all add: tendsto_mult) lemma continuous_setprod [continuous_intros]: fixes f :: "'a \ 'b::t2_space \ 'c::{real_normed_algebra,comm_ring_1}" @@ -1905,17 +1888,8 @@ lemma convergent_setsum: fixes X :: "'a \ nat \ 'b::real_normed_vector" - assumes "\i. i \ A \ convergent (\n. X i n)" - shows "convergent (\n. \i\A. X i n)" -proof (cases "finite A") - case True - then show ?thesis - using assms by (induct A set: finite) (simp_all add: convergent_const convergent_add) -next - case False - then show ?thesis - by (simp add: convergent_const) -qed + shows "(\i. i \ A \ convergent (\n. X i n)) \ convergent (\n. \i\A. X i n)" + by (induct A rule: infinite_finite_induct) (simp_all add: convergent_const convergent_add) lemma (in bounded_linear) convergent: assumes "convergent (\n. X n)" diff -r 255294779d40 -r 5e816da75b8f src/HOL/Real_Vector_Spaces.thy --- a/src/HOL/Real_Vector_Spaces.thy Sun Sep 18 18:36:37 2016 +0200 +++ b/src/HOL/Real_Vector_Spaces.thy Sun Sep 18 21:06:24 2016 +0200 @@ -34,12 +34,7 @@ using add [of x "- y"] by (simp add: minus) lemma setsum: "f (setsum g A) = (\x\A. f (g x))" - apply (cases "finite A") - apply (induct set: finite) - apply (simp add: zero) - apply (simp add: add) - apply (simp add: zero) - done + by (induct A rule: infinite_finite_induct) (simp_all add: zero add) end @@ -223,10 +218,7 @@ lemma setsum_constant_scaleR: "(\x\A. y) = of_nat (card A) *\<^sub>R y" for y :: "'a::real_vector" - apply (cases "finite A") - apply (induct set: finite) - apply (simp_all add: algebra_simps) - done + by (induct A rule: infinite_finite_induct) (simp_all add: algebra_simps) lemma vector_add_divide_simps: "v + (b / z) *\<^sub>R w = (if z = 0 then v else (z *\<^sub>R v + b *\<^sub>R w) /\<^sub>R z)" @@ -475,31 +467,17 @@ then show thesis .. qed -lemma setsum_in_Reals [intro,simp]: - assumes "\i. i \ s \ f i \ \" - shows "setsum f s \ \" -proof (cases "finite s") - case True - then show ?thesis - using assms by (induct s rule: finite_induct) auto -next - case False - then show ?thesis - using assms by (metis Reals_0 setsum.infinite) -qed +lemma setsum_in_Reals [intro,simp]: "(\i. i \ s \ f i \ \) \ setsum f s \ \" +proof (induct s rule: infinite_finite_induct) + case infinite + then show ?case by (metis Reals_0 setsum.infinite) +qed simp_all -lemma setprod_in_Reals [intro,simp]: - assumes "\i. i \ s \ f i \ \" - shows "setprod f s \ \" -proof (cases "finite s") - case True - then show ?thesis - using assms by (induct s rule: finite_induct) auto -next - case False - then show ?thesis - using assms by (metis Reals_1 setprod.infinite) -qed +lemma setprod_in_Reals [intro,simp]: "(\i. i \ s \ f i \ \) \ setprod f s \ \" +proof (induct s rule: infinite_finite_induct) + case infinite + then show ?case by (metis Reals_1 setprod.infinite) +qed simp_all lemma Reals_induct [case_names of_real, induct set: Reals]: "q \ \ \ (\r. P (of_real r)) \ P q" @@ -1572,16 +1550,8 @@ lemma bounded_linear_setsum: fixes f :: "'i \ 'a::real_normed_vector \ 'b::real_normed_vector" - assumes "\i. i \ I \ bounded_linear (f i)" - shows "bounded_linear (\x. \i\I. f i x)" -proof (cases "finite I") - case True - then show ?thesis - using assms by induct (auto intro!: bounded_linear_add) -next - case False - then show ?thesis by simp -qed + shows "(\i. i \ I \ bounded_linear (f i)) \ bounded_linear (\x. \i\I. f i x)" + by (induct I rule: infinite_finite_induct) (auto intro!: bounded_linear_add) lemma bounded_linear_compose: assumes "bounded_linear f" diff -r 255294779d40 -r 5e816da75b8f src/HOL/Set_Interval.thy --- a/src/HOL/Set_Interval.thy Sun Sep 18 18:36:37 2016 +0200 +++ b/src/HOL/Set_Interval.thy Sun Sep 18 21:06:24 2016 +0200 @@ -936,7 +936,7 @@ "Suc ` {.. {0.. {0..n}" - shows "finite N" + shows "finite N" using assms finite_atLeastAtMost by (rule finite_subset) lemma ex_bij_betw_nat_finite: @@ -1992,7 +1992,7 @@ proof assume "m \ ?A" with assms show "m \ ?B" - by auto + by auto next assume "m \ ?B" moreover have "m mod n \ ?A" diff -r 255294779d40 -r 5e816da75b8f src/HOL/Wellfounded.thy --- a/src/HOL/Wellfounded.thy Sun Sep 18 18:36:37 2016 +0200 +++ b/src/HOL/Wellfounded.thy Sun Sep 18 21:06:24 2016 +0200 @@ -790,61 +790,55 @@ assumes wf: "wf r" shows "wf (max_ext r)" proof (rule acc_wfI, intro allI) - fix M - show "M \ acc (max_ext r)" (is "_ \ ?W") - proof (cases "finite M") - case True - then show ?thesis - proof (induct M) - case empty - show ?case - by (rule accI) (auto elim: max_ext.cases) - next - case (insert a M) - from wf \M \ ?W\ \finite M\ show "insert a M \ ?W" - proof (induct arbitrary: M) - fix M a - assume "M \ ?W" - assume [intro]: "finite M" - assume hyp: "\b M. (b, a) \ r \ M \ ?W \ finite M \ insert b M \ ?W" - have add_less: "M \ ?W \ (\y. y \ N \ (y, a) \ r) \ N \ M \ ?W" - if "finite N" "finite M" for N M :: "'a set" - using that by (induct N arbitrary: M) (auto simp: hyp) - show "insert a M \ ?W" - proof (rule accI) - fix N - assume Nless: "(N, insert a M) \ max_ext r" - then have *: "\x. x \ N \ (x, a) \ r \ (\y \ M. (x, y) \ r)" - by (auto elim!: max_ext.cases) + show "M \ acc (max_ext r)" (is "_ \ ?W") for M + proof (induct M rule: infinite_finite_induct) + case empty + show ?case + by (rule accI) (auto elim: max_ext.cases) + next + case (insert a M) + from wf \M \ ?W\ \finite M\ show "insert a M \ ?W" + proof (induct arbitrary: M) + fix M a + assume "M \ ?W" + assume [intro]: "finite M" + assume hyp: "\b M. (b, a) \ r \ M \ ?W \ finite M \ insert b M \ ?W" + have add_less: "M \ ?W \ (\y. y \ N \ (y, a) \ r) \ N \ M \ ?W" + if "finite N" "finite M" for N M :: "'a set" + using that by (induct N arbitrary: M) (auto simp: hyp) + show "insert a M \ ?W" + proof (rule accI) + fix N + assume Nless: "(N, insert a M) \ max_ext r" + then have *: "\x. x \ N \ (x, a) \ r \ (\y \ M. (x, y) \ r)" + by (auto elim!: max_ext.cases) - let ?N1 = "{n \ N. (n, a) \ r}" - let ?N2 = "{n \ N. (n, a) \ r}" - have N: "?N1 \ ?N2 = N" by (rule set_eqI) auto - from Nless have "finite N" by (auto elim: max_ext.cases) - then have finites: "finite ?N1" "finite ?N2" by auto + let ?N1 = "{n \ N. (n, a) \ r}" + let ?N2 = "{n \ N. (n, a) \ r}" + have N: "?N1 \ ?N2 = N" by (rule set_eqI) auto + from Nless have "finite N" by (auto elim: max_ext.cases) + then have finites: "finite ?N1" "finite ?N2" by auto - have "?N2 \ ?W" - proof (cases "M = {}") - case [simp]: True - have Mw: "{} \ ?W" by (rule accI) (auto elim: max_ext.cases) - from * have "?N2 = {}" by auto - with Mw show "?N2 \ ?W" by (simp only:) - next - case False - from * finites have N2: "(?N2, M) \ max_ext r" - by (rule_tac max_extI[OF _ _ \M \ {}\]) auto - with \M \ ?W\ show "?N2 \ ?W" by (rule acc_downward) - qed - with finites have "?N1 \ ?N2 \ ?W" - by (rule add_less) simp - then show "N \ ?W" by (simp only: N) + have "?N2 \ ?W" + proof (cases "M = {}") + case [simp]: True + have Mw: "{} \ ?W" by (rule accI) (auto elim: max_ext.cases) + from * have "?N2 = {}" by auto + with Mw show "?N2 \ ?W" by (simp only:) + next + case False + from * finites have N2: "(?N2, M) \ max_ext r" + by (rule_tac max_extI[OF _ _ \M \ {}\]) auto + with \M \ ?W\ show "?N2 \ ?W" by (rule acc_downward) qed + with finites have "?N1 \ ?N2 \ ?W" + by (rule add_less) simp + then show "N \ ?W" by (simp only: N) qed qed next - case [simp]: False - show ?thesis - by (rule accI) (auto elim: max_ext.cases) + case [simp]: infinite + show ?case by (rule accI) (auto elim: max_ext.cases) qed qed