# HG changeset patch # User desharna # Date 1656156087 -7200 # Node ID a4b47c684445539380e018ed8b23f4ddd52d92a0 # Parent 6d4fb57eb66c80f87f60b7c51ae584cc240833e1 moved mono and strict_mono to Fun and redefined them as abbreviations diff -r 6d4fb57eb66c -r a4b47c684445 NEWS --- a/NEWS Tue Jul 05 09:44:38 2022 +0200 +++ b/NEWS Sat Jun 25 13:21:27 2022 +0200 @@ -53,8 +53,14 @@ compatibility but its usage is discouraged. Minor INCOMPATIBILITY. - Changed argument order of mono_on and strict_mono_on to uniformize with monotone_on and the general "characterizing set at the beginning - of predicates" preference. Also change them to be abbreviation of - monotone_of. Minor INCOMPATIBILITY + of predicates" preference. Also change them to be abbreviations + of monotone_of. Lemmas mono_on_def and strict_mono_on_def are + explicitly provided for backward compatibility but their usage is + discouraged. INCOMPATIBILITY. + - Move mono, strict_mono, and relevant lemmas to Fun theory. Also change + them to be abbreviations of mono_on and strict_mono_on. Lemmas + mono_def and strict_mono_def, are explicitly provided for backward + compatibility but their usage is discouraged. Minor INCOMPATIBILITY. - Added lemmas. monotone_onD monotone_onI diff -r 6d4fb57eb66c -r a4b47c684445 src/Doc/Main/Main_Doc.thy --- a/src/Doc/Main/Main_Doc.thy Tue Jul 05 09:44:38 2022 +0200 +++ b/src/Doc/Main/Main_Doc.thy Sat Jun 25 13:21:27 2022 +0200 @@ -58,8 +58,6 @@ \<^const>\Orderings.max\ & \<^typeof>\Orderings.max\\\ @{const[source] top} & \<^typeof>\Orderings.top\\\ @{const[source] bot} & \<^typeof>\Orderings.bot\\\ -\<^const>\Orderings.mono\ & \<^typeof>\Orderings.mono\\\ -\<^const>\Orderings.strict_mono\ & \<^typeof>\Orderings.strict_mono\\\ \end{tabular} \subsubsection*{Syntax} @@ -152,6 +150,12 @@ \<^const>\Fun.surj\ & \<^typeof>\Fun.surj\\\ \<^const>\Fun.bij\ & \<^typeof>\Fun.bij\\\ \<^const>\Fun.bij_betw\ & @{term_type_only Fun.bij_betw "('a\'b)\'a set\'b set\bool"}\\ +\<^const>\Fun.monotone_on\ & \<^typeof>\Fun.monotone_on\\\ +\<^const>\Fun.monotone\ & \<^typeof>\Fun.monotone\\\ +\<^const>\Fun.mono_on\ & \<^typeof>\Fun.mono_on\\\ +\<^const>\Fun.mono\ & \<^typeof>\Fun.mono\\\ +\<^const>\Fun.strict_mono_on\ & \<^typeof>\Fun.strict_mono_on\\\ +\<^const>\Fun.strict_mono\ & \<^typeof>\Fun.strict_mono\\\ \<^const>\Fun.fun_upd\ & \<^typeof>\Fun.fun_upd\\\ \end{tabular} diff -r 6d4fb57eb66c -r a4b47c684445 src/HOL/Fun.thy --- a/src/HOL/Fun.thy Tue Jul 05 09:44:38 2022 +0200 +++ b/src/HOL/Fun.thy Sat Jun 25 13:21:27 2022 +0200 @@ -590,9 +590,6 @@ lemma (in ordered_ab_group_add) inj_uminus[simp, intro]: "inj_on uminus A" by (auto intro!: inj_onI) -lemma (in linorder) strict_mono_imp_inj_on: "strict_mono f \ inj_on f A" - by (auto intro!: inj_onI dest: strict_mono_eq) - lemma bij_betw_byWitness: assumes left: "\a \ A. f' (f a) = a" and right: "\a' \ A'. f (f' a') = a'" @@ -931,7 +928,7 @@ qed -subsection \Monotonic functions over a set\ +subsection \Monotonicity\ definition monotone_on :: "'a set \ ('a \ 'a \ bool) \ ('b \ 'b \ bool) \ ('a \ 'b) \ bool" where "monotone_on A orda ordb f \ (\x\A. \y\A. orda x y \ ordb (f x) (f y))" @@ -980,39 +977,45 @@ using mono_f[THEN monotone_onD] by simp qed -abbreviation mono_on :: "('a :: ord) set \ ('a \ 'b :: ord) \ bool" + +subsubsection \Specializations For @{class ord} Type Class And More\ + +context ord begin + +abbreviation mono_on :: "'a set \ ('a \ 'b :: ord) \ bool" where "mono_on A \ monotone_on A (\) (\)" -lemma mono_on_def: "mono_on A f \ (\r s. r \ A \ s \ A \ r \ s \ f r \ f s)" +abbreviation strict_mono_on :: "'a set \ ('a \ 'b :: ord) \ bool" + where "strict_mono_on A \ monotone_on A (<) (<)" + +lemma mono_on_def[no_atp]: "mono_on A f \ (\r s. r \ A \ s \ A \ r \ s \ f r \ f s)" by (auto simp add: monotone_on_def) +lemma strict_mono_on_def[no_atp]: + "strict_mono_on A f \ (\r s. r \ A \ s \ A \ r < s \ f r < f s)" + by (auto simp add: monotone_on_def) + +text \Lemmas @{thm [source] mono_on_def} and @{thm [source] strict_mono_on_def} are provided for +backward compatibility.\ + lemma mono_onI: "(\r s. r \ A \ s \ A \ r \ s \ f r \ f s) \ mono_on A f" by (rule monotone_onI) -lemma mono_onD: - "\mono_on A f; r \ A; s \ A; r \ s\ \ f r \ f s" +lemma strict_mono_onI: + "(\r s. r \ A \ s \ A \ r < s \ f r < f s) \ strict_mono_on A f" + by (rule monotone_onI) + +lemma mono_onD: "\mono_on A f; r \ A; s \ A; r \ s\ \ f r \ f s" by (rule monotone_onD) -lemma mono_imp_mono_on: "mono f \ mono_on A f" - unfolding mono_def mono_on_def by auto +lemma strict_mono_onD: "\strict_mono_on A f; r \ A; s \ A; r < s\ \ f r < f s" + by (rule monotone_onD) lemma mono_on_subset: "mono_on A f \ B \ A \ mono_on B f" by (rule monotone_on_subset) -abbreviation strict_mono_on :: "('a :: ord) set \ ('a \ 'b :: ord) \ bool" - where "strict_mono_on A \ monotone_on A (<) (<)" - -lemma strict_mono_on_def: "strict_mono_on A f \ (\r s. r \ A \ s \ A \ r < s \ f r < f s)" - by (auto simp add: monotone_on_def) - -lemma strict_mono_onI: - "(\r s. r \ A \ s \ A \ r < s \ f r < f s) \ strict_mono_on A f" - by (rule monotone_onI) - -lemma strict_mono_onD: - "\strict_mono_on A f; r \ A; s \ A; r < s\ \ f r < f s" - by (rule monotone_onD) +end lemma mono_on_greaterD: assumes "mono_on A g" "x \ A" "y \ A" "g x > (g (y::_::linorder) :: _ :: linorder)" @@ -1024,6 +1027,136 @@ with assms(4) show False by simp qed +context order begin + +abbreviation mono :: "('a \ 'b::order) \ bool" + where "mono \ mono_on UNIV" + +abbreviation strict_mono :: "('a \ 'b::order) \ bool" + where "strict_mono \ strict_mono_on UNIV" + +lemma mono_def[no_atp]: "mono f \ (\x y. x \ y \ f x \ f y)" + by (simp add: monotone_on_def) + +lemma strict_mono_def[no_atp]: "strict_mono f \ (\x y. x < y \ f x < f y)" + by (simp add: monotone_on_def) + +text \Lemmas @{thm [source] mono_def} and @{thm [source] strict_mono_def} are provided for backward +compatibility.\ + +lemma monoI [intro?]: "(\x y. x \ y \ f x \ f y) \ mono f" + by (rule monotoneI) + +lemma strict_monoI [intro?]: "(\x y. x < y \ f x < f y) \ strict_mono f" + by (rule monotoneI) + +lemma monoD [dest?]: "mono f \ x \ y \ f x \ f y" + by (rule monotoneD) + +lemma strict_monoD [dest?]: "strict_mono f \ x < y \ f x < f y" + by (rule monotoneD) + +lemma monoE: + assumes "mono f" + assumes "x \ y" + obtains "f x \ f y" +proof + from assms show "f x \ f y" by (simp add: mono_def) +qed + +lemma mono_imp_mono_on: "mono f \ mono_on A f" + by (rule monotone_on_subset[OF _ subset_UNIV]) + +lemma strict_mono_mono [dest?]: + assumes "strict_mono f" + shows "mono f" +proof (rule monoI) + fix x y + assume "x \ y" + show "f x \ f y" + proof (cases "x = y") + case True then show ?thesis by simp + next + case False with \x \ y\ have "x < y" by simp + with assms strict_monoD have "f x < f y" by auto + then show ?thesis by simp + + qed +qed + +end + +context linorder begin + +lemma mono_invE: + fixes f :: "'a \ 'b::order" + assumes "mono f" + assumes "f x < f y" + obtains "x \ y" +proof + show "x \ y" + proof (rule ccontr) + assume "\ x \ y" + then have "y \ x" by simp + with \mono f\ obtain "f y \ f x" by (rule monoE) + with \f x < f y\ show False by simp + qed +qed + +lemma mono_strict_invE: + fixes f :: "'a \ 'b::order" + assumes "mono f" + assumes "f x < f y" + obtains "x < y" +proof + show "x < y" + proof (rule ccontr) + assume "\ x < y" + then have "y \ x" by simp + with \mono f\ obtain "f y \ f x" by (rule monoE) + with \f x < f y\ show False by simp + qed +qed + +lemma strict_mono_eq: + assumes "strict_mono f" + shows "f x = f y \ x = y" +proof + assume "f x = f y" + show "x = y" proof (cases x y rule: linorder_cases) + case less with assms strict_monoD have "f x < f y" by auto + with \f x = f y\ show ?thesis by simp + next + case equal then show ?thesis . + next + case greater with assms strict_monoD have "f y < f x" by auto + with \f x = f y\ show ?thesis by simp + qed +qed simp + +lemma strict_mono_less_eq: + assumes "strict_mono f" + shows "f x \ f y \ x \ y" +proof + assume "x \ y" + with assms strict_mono_mono monoD show "f x \ f y" by auto +next + assume "f x \ f y" + show "x \ y" proof (rule ccontr) + assume "\ x \ y" then have "y < x" by simp + with assms strict_monoD have "f y < f x" by auto + with \f x \ f y\ show False by simp + qed +qed + +lemma strict_mono_less: + assumes "strict_mono f" + shows "f x < f y \ x < y" + using assms + by (auto simp add: less_le Orderings.less_le strict_mono_eq strict_mono_less_eq) + +end + lemma strict_mono_inv: fixes f :: "('a::linorder) \ ('b::linorder)" assumes "strict_mono f" and "surj f" and inv: "\x. g (f x) = x" @@ -1064,6 +1197,50 @@ "strict_mono_on A (f :: (_ :: linorder) \ _ :: preorder) \ mono_on A f" by (rule mono_onI, rule strict_mono_on_leD) +lemma mono_compose: "mono Q \ mono (\i x. Q i (f x))" + unfolding mono_def le_fun_def by auto + +lemma mono_add: + fixes a :: "'a::ordered_ab_semigroup_add" + shows "mono ((+) a)" + by (simp add: add_left_mono monoI) + +lemma (in semilattice_inf) mono_inf: "mono f \ f (A \ B) \ f A \ f B" + for f :: "'a \ 'b::semilattice_inf" + by (auto simp add: mono_def intro: Lattices.inf_greatest) + +lemma (in semilattice_sup) mono_sup: "mono f \ f A \ f B \ f (A \ B)" + for f :: "'a \ 'b::semilattice_sup" + by (auto simp add: mono_def intro: Lattices.sup_least) + +lemma (in linorder) min_of_mono: "mono f \ min (f m) (f n) = f (min m n)" + by (auto simp: mono_def Orderings.min_def min_def intro: Orderings.antisym) + +lemma (in linorder) max_of_mono: "mono f \ max (f m) (f n) = f (max m n)" + by (auto simp: mono_def Orderings.max_def max_def intro: Orderings.antisym) + +lemma (in linorder) strict_mono_imp_inj_on: "strict_mono f \ inj_on f A" + by (auto intro!: inj_onI dest: strict_mono_eq) + +lemma mono_Int: "mono f \ f (A \ B) \ f A \ f B" + by (fact mono_inf) + +lemma mono_Un: "mono f \ f A \ f B \ f (A \ B)" + by (fact mono_sup) + + +subsubsection \Least value operator\ + +lemma Least_mono: "mono f \ \x\S. \y\S. x \ y \ (LEAST y. y \ f ` S) = f (LEAST x. x \ S)" + for f :: "'a::order \ 'b::order" + \ \Courtesy of Stephan Merz\ + apply clarify + apply (erule_tac P = "\x. x \ S" in LeastI2_order) + apply fast + apply (rule LeastI2_order) + apply (auto elim: monoD intro!: order_antisym) + done + subsection \Setup\ diff -r 6d4fb57eb66c -r a4b47c684445 src/HOL/Groups.thy --- a/src/HOL/Groups.thy Tue Jul 05 09:44:38 2022 +0200 +++ b/src/HOL/Groups.thy Sat Jun 25 13:21:27 2022 +0200 @@ -639,11 +639,6 @@ end -lemma mono_add: - fixes a :: "'a::ordered_ab_semigroup_add" - shows "mono ((+) a)" - by (simp add: add_left_mono monoI) - text \Strict monotonicity in both arguments\ class strict_ordered_ab_semigroup_add = ordered_ab_semigroup_add + assumes add_strict_mono: "a < b \ c < d \ a + c < b + d" diff -r 6d4fb57eb66c -r a4b47c684445 src/HOL/Lattices.thy --- a/src/HOL/Lattices.thy Tue Jul 05 09:44:38 2022 +0200 +++ b/src/HOL/Lattices.thy Sat Jun 25 13:21:27 2022 +0200 @@ -220,9 +220,6 @@ lemma inf_mono: "a \ c \ b \ d \ a \ b \ c \ d" by (fast intro: inf_greatest le_infI1 le_infI2) -lemma mono_inf: "mono f \ f (A \ B) \ f A \ f B" for f :: "'a \ 'b::semilattice_inf" - by (auto simp add: mono_def intro: Lattices.inf_greatest) - end context semilattice_sup @@ -249,9 +246,6 @@ lemma sup_mono: "a \ c \ b \ d \ a \ b \ c \ d" by (fast intro: sup_least le_supI1 le_supI2) -lemma mono_sup: "mono f \ f A \ f B \ f (A \ B)" for f :: "'a \ 'b::semilattice_sup" - by (auto simp add: mono_def intro: Lattices.sup_least) - end @@ -610,12 +604,6 @@ \P (max a b) \ (b = a \ P a) \ (a < b \ P b) \ (b < a \ P a)\ by (cases a b rule: linorder_cases) auto -lemma min_of_mono: "mono f \ min (f m) (f n) = f (min m n)" for f :: "'a \ 'b::linorder" - by (auto simp: mono_def Orderings.min_def min_def intro: Orderings.antisym) - -lemma max_of_mono: "mono f \ max (f m) (f n) = f (max m n)" for f :: "'a \ 'b::linorder" - by (auto simp: mono_def Orderings.max_def max_def intro: Orderings.antisym) - end lemma max_of_antimono: "antimono f \ max (f x) (f y) = f (min x y)" diff -r 6d4fb57eb66c -r a4b47c684445 src/HOL/Orderings.thy --- a/src/HOL/Orderings.thy Tue Jul 05 09:44:38 2022 +0200 +++ b/src/HOL/Orderings.thy Sat Jun 25 13:21:27 2022 +0200 @@ -1063,28 +1063,6 @@ context order begin -definition mono :: "('a \ 'b::order) \ bool" where - "mono f \ (\x y. x \ y \ f x \ f y)" - -lemma monoI [intro?]: - fixes f :: "'a \ 'b::order" - shows "(\x y. x \ y \ f x \ f y) \ mono f" - unfolding mono_def by iprover - -lemma monoD [dest?]: - fixes f :: "'a \ 'b::order" - shows "mono f \ x \ y \ f x \ f y" - unfolding mono_def by iprover - -lemma monoE: - fixes f :: "'a \ 'b::order" - assumes "mono f" - assumes "x \ y" - obtains "f x \ f y" -proof - from assms show "f x \ f y" by (simp add: mono_def) -qed - definition antimono :: "('a \ 'b::order) \ bool" where "antimono f \ (\x y. x \ y \ f x \ f y)" @@ -1107,107 +1085,6 @@ from assms show "f x \ f y" by (simp add: antimono_def) qed -definition strict_mono :: "('a \ 'b::order) \ bool" where - "strict_mono f \ (\x y. x < y \ f x < f y)" - -lemma strict_monoI [intro?]: - assumes "\x y. x < y \ f x < f y" - shows "strict_mono f" - using assms unfolding strict_mono_def by auto - -lemma strict_monoD [dest?]: - "strict_mono f \ x < y \ f x < f y" - unfolding strict_mono_def by auto - -lemma strict_mono_mono [dest?]: - assumes "strict_mono f" - shows "mono f" -proof (rule monoI) - fix x y - assume "x \ y" - show "f x \ f y" - proof (cases "x = y") - case True then show ?thesis by simp - next - case False with \x \ y\ have "x < y" by simp - with assms strict_monoD have "f x < f y" by auto - then show ?thesis by simp - - qed -qed - -end - -context linorder -begin - -lemma mono_invE: - fixes f :: "'a \ 'b::order" - assumes "mono f" - assumes "f x < f y" - obtains "x \ y" -proof - show "x \ y" - proof (rule ccontr) - assume "\ x \ y" - then have "y \ x" by simp - with \mono f\ obtain "f y \ f x" by (rule monoE) - with \f x < f y\ show False by simp - qed -qed - -lemma mono_strict_invE: - fixes f :: "'a \ 'b::order" - assumes "mono f" - assumes "f x < f y" - obtains "x < y" -proof - show "x < y" - proof (rule ccontr) - assume "\ x < y" - then have "y \ x" by simp - with \mono f\ obtain "f y \ f x" by (rule monoE) - with \f x < f y\ show False by simp - qed -qed - -lemma strict_mono_eq: - assumes "strict_mono f" - shows "f x = f y \ x = y" -proof - assume "f x = f y" - show "x = y" proof (cases x y rule: linorder_cases) - case less with assms strict_monoD have "f x < f y" by auto - with \f x = f y\ show ?thesis by simp - next - case equal then show ?thesis . - next - case greater with assms strict_monoD have "f y < f x" by auto - with \f x = f y\ show ?thesis by simp - qed -qed simp - -lemma strict_mono_less_eq: - assumes "strict_mono f" - shows "f x \ f y \ x \ y" -proof - assume "x \ y" - with assms strict_mono_mono monoD show "f x \ f y" by auto -next - assume "f x \ f y" - show "x \ y" proof (rule ccontr) - assume "\ x \ y" then have "y < x" by simp - with assms strict_monoD have "f y < f x" by auto - with \f x \ f y\ show False by simp - qed -qed - -lemma strict_mono_less: - assumes "strict_mono f" - shows "f x < f y \ x < y" - using assms - by (auto simp add: less_le Orderings.less_le strict_mono_eq strict_mono_less_eq) - end @@ -1614,9 +1491,6 @@ lemma le_funD: "f \ g \ f x \ g x" by (rule le_funE) -lemma mono_compose: "mono Q \ mono (\i x. Q i (f x))" - unfolding mono_def le_fun_def by auto - subsection \Order on unary and binary predicates\ diff -r 6d4fb57eb66c -r a4b47c684445 src/HOL/Set.thy --- a/src/HOL/Set.thy Tue Jul 05 09:44:38 2022 +0200 +++ b/src/HOL/Set.thy Sat Jun 25 13:21:27 2022 +0200 @@ -666,9 +666,6 @@ lemma IntE [elim!]: "c \ A \ B \ (c \ A \ c \ B \ P) \ P" by simp -lemma mono_Int: "mono f \ f (A \ B) \ f A \ f B" - by (fact mono_inf) - subsubsection \Binary union\ @@ -700,9 +697,6 @@ lemma insert_def: "insert a B = {x. x = a} \ B" by (simp add: insert_compr Un_def) -lemma mono_Un: "mono f \ f A \ f B \ f (A \ B)" - by (fact mono_sup) - subsubsection \Set difference\ @@ -1808,19 +1802,6 @@ qed -subsubsection \Least value operator\ - -lemma Least_mono: "mono f \ \x\S. \y\S. x \ y \ (LEAST y. y \ f ` S) = f (LEAST x. x \ S)" - for f :: "'a::order \ 'b::order" - \ \Courtesy of Stephan Merz\ - apply clarify - apply (erule_tac P = "\x. x \ S" in LeastI2_order) - apply fast - apply (rule LeastI2_order) - apply (auto elim: monoD intro!: order_antisym) - done - - subsubsection \Monad operation\ definition bind :: "'a set \ ('a \ 'b set) \ 'b set" diff -r 6d4fb57eb66c -r a4b47c684445 src/HOL/Tools/inductive.ML --- a/src/HOL/Tools/inductive.ML Tue Jul 05 09:44:38 2022 +0200 +++ b/src/HOL/Tools/inductive.ML Sat Jun 25 13:21:27 2022 +0200 @@ -399,7 +399,8 @@ (if skip_mono then Goal.prove_sorry else Goal.prove_future) ctxt [] [] (HOLogic.mk_Trueprop - (Const (\<^const_name>\Orderings.mono\, (predT --> predT) --> HOLogic.boolT) $ fp_fun)) + (\<^Const>\monotone_on predT predT for + \<^Const>\top \<^Type>\set predT\\ \<^Const>\less_eq predT\ \<^Const>\less_eq predT\ fp_fun\)) (fn _ => EVERY [resolve_tac ctxt @{thms monoI} 1, REPEAT (resolve_tac ctxt [@{thm le_funI}, @{thm le_boolI'}] 1), REPEAT (FIRST