equal
deleted
inserted
replaced
983 |
983 |
984 lemma arg_max_nat_le: "P x \<Longrightarrow> \<forall>y. P y \<longrightarrow> f y < b \<Longrightarrow> f x \<le> f (arg_max f P)" |
984 lemma arg_max_nat_le: "P x \<Longrightarrow> \<forall>y. P y \<longrightarrow> f y < b \<Longrightarrow> f x \<le> f (arg_max f P)" |
985 for f :: "'a \<Rightarrow> nat" |
985 for f :: "'a \<Rightarrow> nat" |
986 by (blast dest: arg_max_nat_lemma [THEN conjunct2, THEN spec, of P]) |
986 by (blast dest: arg_max_nat_lemma [THEN conjunct2, THEN spec, of P]) |
987 |
987 |
988 (* |
988 end |
989 text \<open>\<^medskip> Specialization to \<open>GREATEST\<close>.\<close> |
|
990 |
|
991 (* LEAST ? *) |
|
992 definition Greatest :: "('a::ord \<Rightarrow> bool) \<Rightarrow> 'a" (binder "GREATEST " 10) |
|
993 where "Greatest \<equiv> arg_max (\<lambda>x. x)" |
|
994 |
|
995 lemma Greatest_equality: |
|
996 "\<lbrakk> P k; \<And>x. P x \<Longrightarrow> x \<le> k \<rbrakk> \<Longrightarrow> (Greatest P) = k" |
|
997 for k :: "'a::order" |
|
998 apply (simp add: Greatest_def) |
|
999 apply (erule arg_max_equality) |
|
1000 apply blast |
|
1001 done |
|
1002 |
|
1003 lemma GreatestI: "P k \<Longrightarrow> \<forall>y. P y \<longrightarrow> y < b \<Longrightarrow> P (Greatest P)" |
|
1004 for k :: nat |
|
1005 unfolding Greatest_def by (rule arg_max_natI) auto |
|
1006 |
|
1007 lemma Greatest_le: "P x \<Longrightarrow> \<forall>y. P y \<longrightarrow> y < b \<Longrightarrow> x \<le> (Greatest P)" |
|
1008 for x :: nat |
|
1009 unfolding Greatest_def by (rule arg_max_nat_le) auto |
|
1010 |
|
1011 lemma GreatestI_ex: "\<exists>k::nat. P k \<Longrightarrow> \<forall>y. P y \<longrightarrow> y < b \<Longrightarrow> P (Greatest P)" |
|
1012 apply (erule exE) |
|
1013 apply (erule (1) GreatestI) |
|
1014 done |
|
1015 *) |
|
1016 end |
|