(* Una_funcion_creciente_e_involutiva_es_la_identidad.thy -- Si una función es creciente e involutiva, entonces es la identidad -- José A. Alonso Jiménez -- Sevilla, 22-mayo-2024 -- ------------------------------------------------------------------ *) (* --------------------------------------------------------------------- -- Sea una función f de \ en \. -- + Se dice que f es creciente si para todo x e y tales que x \ y se -- tiene que f(x) \ f(y). -- + Se dice que f es involutiva si para todo x se tiene que f(f(x)) = x. -- -- En Isabelle/HOL que f sea creciente se representa por `mono f`. -- -- Demostrar que si f es creciente e involutiva, entonces f es la -- identidad. -- ------------------------------------------------------------------ *) theory Una_funcion_creciente_e_involutiva_es_la_identidad imports Main HOL.Real begin definition involutiva :: "(real \ real) \ bool" where "involutiva f \ (\x. f (f x) = x)" (* 1\ demostración *) lemma fixes f :: "real \ real" assumes "mono f" "involutiva f" shows "f = id" proof (unfold fun_eq_iff; intro allI) fix x have "x \ f x \ f x \ x" by (rule linear) then have "f x = x" proof (rule disjE) assume "x \ f x" then have "f x \ f (f x)" using assms(1) by (simp only: monoD) also have "\ = x" using assms(2) by (simp only: involutiva_def) finally have "f x \ x" by this show "f x = x" using \f x \ x\ \x \ f x\ by (simp only: antisym) next assume "f x \ x" have "x = f (f x)" using assms(2) by (simp only: involutiva_def) also have "... \ f x" using \f x \ x\ assms(1) by (simp only: monoD) finally have "x \ f x" by this show "f x = x" using \f x \ x\ \x \ f x\ by (simp only: monoD) qed then show "f x = id x" by (simp only: id_apply) qed (* 2\ demostración *) lemma fixes f :: "real \ real" assumes "mono f" "involutiva f" shows "f = id" proof fix x have "x \ f x \ f x \ x" by (rule linear) then have "f x = x" proof assume "x \ f x" then have "f x \ f (f x)" using assms(1) by (simp only: monoD) also have "\ = x" using assms(2) by (simp only: involutiva_def) finally have "f x \ x" by this show "f x = x" using \f x \ x\ \x \ f x\ by auto next assume "f x \ x" have "x = f (f x)" using assms(2) by (simp only: involutiva_def) also have "... \ f x" by (simp add: \f x \ x\ assms(1) monoD) finally have "x \ f x" by this show "f x = x" using \f x \ x\ \x \ f x\ by auto qed then show "f x = id x" by simp qed (* 3\ demostración *) lemma fixes f :: "real \ real" assumes "mono f" "involutiva f" shows "f = id" proof fix x have "x \ f x \ f x \ x" by (rule linear) then have "f x = x" proof assume "x \ f x" then have "f x \ x" by (metis assms involutiva_def mono_def) then show "f x = x" using \x \ f x\ by auto next assume "f x \ x" then have "x \ f x" by (metis assms involutiva_def mono_def) then show "f x = x" using \f x \ x\ by auto qed then show "f x = id x" by simp qed end