# HG changeset patch # User nipkow # Date 1601996156 -7200 # Node ID b037517c815bad1b9002eadb8154993f334cd169 # Parent 698b58513fd1021d9ad5c6549183b3313cec57c8 added lemmas; internalized defn in class diff -r 698b58513fd1 -r b037517c815b src/HOL/Finite_Set.thy --- a/src/HOL/Finite_Set.thy Mon Oct 05 22:53:40 2020 +0100 +++ b/src/HOL/Finite_Set.thy Tue Oct 06 16:55:56 2020 +0200 @@ -2057,6 +2057,58 @@ qed qed +subsubsection \Finite orders\ + +context order +begin + +lemma finite_has_maximal: + "\ finite A; A \ {} \ \ \ m \ A. \ b \ A. m \ b \ m = b" +proof (induction rule: finite_psubset_induct) + case (psubset A) + from \A \ {}\ obtain a where "a \ A" by auto + let ?B = "{b \ A. a < b}" + show ?case + proof cases + assume "?B = {}" + hence "\ b \ A. a \ b \ a = b" using le_neq_trans by blast + thus ?thesis using \a \ A\ by blast + next + assume "?B \ {}" + have "a \ ?B" by auto + hence "?B \ A" using \a \ A\ by blast + from psubset.IH[OF this \?B \ {}\] show ?thesis using order.strict_trans2 by blast + qed +qed + +lemma finite_has_maximal2: + "\ finite A; a \ A \ \ \ m \ A. a \ m \ (\ b \ A. m \ b \ m = b)" +using finite_has_maximal[of "{b \ A. a \ b}"] by fastforce + +lemma finite_has_minimal: + "\ finite A; A \ {} \ \ \ m \ A. \ b \ A. b \ m \ m = b" +proof (induction rule: finite_psubset_induct) + case (psubset A) + from \A \ {}\ obtain a where "a \ A" by auto + let ?B = "{b \ A. b < a}" + show ?case + proof cases + assume "?B = {}" + hence "\ b \ A. b \ a \ a = b" using le_neq_trans by blast + thus ?thesis using \a \ A\ by blast + next + assume "?B \ {}" + have "a \ ?B" by auto + hence "?B \ A" using \a \ A\ by blast + from psubset.IH[OF this \?B \ {}\] show ?thesis using order.strict_trans1 by blast + qed +qed + +lemma finite_has_minimal2: + "\ finite A; a \ A \ \ \ m \ A. m \ a \ (\ b \ A. b \ m \ m = b)" +using finite_has_minimal[of "{b \ A. b \ a}"] by fastforce + +end subsubsection \Relating injectivity and surjectivity\ diff -r 698b58513fd1 -r b037517c815b src/HOL/Lattices_Big.thy --- a/src/HOL/Lattices_Big.thy Mon Oct 05 22:53:40 2020 +0100 +++ b/src/HOL/Lattices_Big.thy Tue Oct 06 16:55:56 2020 +0200 @@ -868,17 +868,22 @@ subsection \Arg Min\ -definition is_arg_min :: "('a \ 'b::ord) \ ('a \ bool) \ 'a \ bool" where +context ord +begin + +definition is_arg_min :: "('b \ 'a) \ ('b \ bool) \ 'b \ bool" where "is_arg_min f P x = (P x \ \(\y. P y \ f y < f x))" -definition arg_min :: "('a \ 'b::ord) \ ('a \ bool) \ 'a" where +definition arg_min :: "('b \ 'a) \ ('b \ bool) \ 'b" where "arg_min f P = (SOME x. is_arg_min f P x)" -definition arg_min_on :: "('a \ 'b::ord) \ 'a set \ 'a" where +definition arg_min_on :: "('b \ 'a) \ 'b set \ 'b" where "arg_min_on f S = arg_min f (\x. x \ S)" +end + syntax - "_arg_min" :: "('a \ 'b) \ pttrn \ bool \ 'a" + "_arg_min" :: "('b \ 'a) \ pttrn \ bool \ 'b" ("(3ARG'_MIN _ _./ _)" [1000, 0, 10] 10) translations "ARG_MIN f x. P" \ "CONST arg_min f (\x. P)" @@ -980,17 +985,22 @@ subsection \Arg Max\ -definition is_arg_max :: "('a \ 'b::ord) \ ('a \ bool) \ 'a \ bool" where +context ord +begin + +definition is_arg_max :: "('b \ 'a) \ ('b \ bool) \ 'b \ bool" where "is_arg_max f P x = (P x \ \(\y. P y \ f y > f x))" -definition arg_max :: "('a \ 'b::ord) \ ('a \ bool) \ 'a" where +definition arg_max :: "('b \ 'a) \ ('b \ bool) \ 'b" where "arg_max f P = (SOME x. is_arg_max f P x)" -definition arg_max_on :: "('a \ 'b::ord) \ 'a set \ 'a" where +definition arg_max_on :: "('b \ 'a) \ 'b set \ 'b" where "arg_max_on f S = arg_max f (\x. x \ S)" +end + syntax - "_arg_max" :: "('a \ 'b) \ pttrn \ bool \ 'a" + "_arg_max" :: "('b \ 'a) \ pttrn \ bool \ 'a" ("(3ARG'_MAX _ _./ _)" [1000, 0, 10] 10) translations "ARG_MAX f x. P" \ "CONST arg_max f (\x. P)"