736 |
736 |
737 lemma finite_linorder_min_induct [consumes 1, case_names empty insert]: |
737 lemma finite_linorder_min_induct [consumes 1, case_names empty insert]: |
738 "\<lbrakk>finite A; P {}; \<And>b A. \<lbrakk>finite A; \<forall>a\<in>A. b < a; P A\<rbrakk> \<Longrightarrow> P (insert b A)\<rbrakk> \<Longrightarrow> P A" |
738 "\<lbrakk>finite A; P {}; \<And>b A. \<lbrakk>finite A; \<forall>a\<in>A. b < a; P A\<rbrakk> \<Longrightarrow> P (insert b A)\<rbrakk> \<Longrightarrow> P A" |
739 by (rule linorder.finite_linorder_max_induct [OF dual_linorder]) |
739 by (rule linorder.finite_linorder_max_induct [OF dual_linorder]) |
740 |
740 |
|
741 lemma finite_ranking_induct[consumes 1, case_names empty insert]: |
|
742 fixes f :: "'b \<Rightarrow> 'a" |
|
743 assumes "finite S" |
|
744 assumes "P {}" |
|
745 assumes "\<And>x S. finite S \<Longrightarrow> (\<And>y. y \<in> S \<Longrightarrow> f y \<le> f x) \<Longrightarrow> P S \<Longrightarrow> P (insert x S)" |
|
746 shows "P S" |
|
747 using `finite S` |
|
748 proof (induction rule: finite_psubset_induct) |
|
749 case (psubset A) |
|
750 { |
|
751 assume "A \<noteq> {}" |
|
752 hence "f ` A \<noteq> {}" and "finite (f ` A)" |
|
753 using psubset finite_image_iff by simp+ |
|
754 then obtain a where "f a = Max (f ` A)" and "a \<in> A" |
|
755 by (metis Max_in[of "f ` A"] imageE) |
|
756 then have "P (A - {a})" |
|
757 using psubset member_remove by blast |
|
758 moreover |
|
759 have "\<And>y. y \<in> A \<Longrightarrow> f y \<le> f a" |
|
760 using \<open>f a = Max (f ` A)\<close> \<open>finite (f ` A)\<close> by simp |
|
761 ultimately |
|
762 have ?case |
|
763 by (metis \<open>a \<in> A\<close> DiffD1 insert_Diff assms(3) finite_Diff psubset.hyps) |
|
764 } |
|
765 thus ?case |
|
766 using assms(2) by blast |
|
767 qed |
|
768 |
741 lemma Least_Min: |
769 lemma Least_Min: |
742 assumes "finite {a. P a}" and "\<exists>a. P a" |
770 assumes "finite {a. P a}" and "\<exists>a. P a" |
743 shows "(LEAST a. P a) = Min {a. P a}" |
771 shows "(LEAST a. P a) = Min {a. P a}" |
744 proof - |
772 proof - |
745 { fix A :: "'a set" |
773 { fix A :: "'a set" |