        {"id":639,"date":"2021-08-09T06:00:36","date_gmt":"2021-08-09T04:00:36","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=639"},"modified":"2021-08-05T16:23:03","modified_gmt":"2021-08-05T14:23:03","slug":"las-funciones-biyectivas-tienen-inversa","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/las-funciones-biyectivas-tienen-inversa\/","title":{"rendered":"Las funciones biyectivas tienen inversa"},"content":{"rendered":"<p>En Lean se puede definir que g es una inversa de f por<\/p>\n<pre lang=\"text\">\n   def inversa (f : X \u2192 Y) (g : Y \u2192 X) :=\n     (\u2200 x, (g \u2218 f) x = x) \u2227 (\u2200 y, (f \u2218 g) y = y)\n<\/pre>\n<p>y que f tiene inversa por<\/p>\n<pre lang=\"text\">\n   def tiene_inversa (f : X \u2192 Y) :=\n     \u2203 g, inversa g f\n<\/pre>\n<p>Demostrar que si la funci\u00f3n f es biyectiva, entonces f tiene inversa.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/p>\n<pre lang=\"lean\">\nimport tactic\nopen function\n\nvariables {X Y : Type*}\nvariable  (f : X \u2192 Y)\n\ndef inversa (f : X \u2192 Y) (g : Y \u2192 X) :=\n  (\u2200 x, (g \u2218 f) x = x) \u2227 (\u2200 y, (f \u2218 g) y = y)\n\ndef tiene_inversa (f : X \u2192 Y) :=\n  \u2203 g, inversa g f\n\nexample\n  (hf : bijective f)\n  : tiene_inversa f :=\nsorry\n<\/pre>\n<p>[expand title=\u00bbSoluciones con Lean\u00bb]<\/p>\n<pre lang=\"lean\">\r\nimport tactic\r\nopen function\r\n\r\nvariables {X Y : Type*}\r\nvariable  (f : X \u2192 Y)\r\n\r\ndef inversa (f : X \u2192 Y) (g : Y \u2192 X) :=\r\n  (\u2200 x, (g \u2218 f) x = x) \u2227 (\u2200 y, (f \u2218 g) y = y)\r\n\r\ndef tiene_inversa (f : X \u2192 Y) :=\r\n  \u2203 g, inversa g f\r\n\r\n-- 1\u00aa demostraci\u00f3n\r\nexample\r\n  (hf : bijective f)\r\n  : tiene_inversa f :=\r\nbegin\r\n  rcases hf with \u27e8hfiny, hfsup\u27e9,\r\n  choose g hg using hfsup,\r\n  use g,\r\n  split,\r\n  { exact hg, },\r\n  { intro a,\r\n    apply hfiny,\r\n    rw hg (f a), },\r\nend\r\n\r\n-- 2\u00aa demostraci\u00f3n\r\nexample\r\n  (hf : bijective f)\r\n  : tiene_inversa f :=\r\nbegin\r\n  rcases hf with \u27e8hfiny, hfsup\u27e9,\r\n  choose g hg using hfsup,\r\n  use g,\r\n  split,\r\n  { exact hg, },\r\n  { intro a,\r\n    exact @hfiny (g (f a)) a (hg (f a)), },\r\nend\r\n\r\n-- 3\u00aa demostraci\u00f3n\r\nexample\r\n  (hf : bijective f)\r\n  : tiene_inversa f :=\r\nbegin\r\n  rcases hf with \u27e8hfiny, hfsup\u27e9,\r\n  choose g hg using hfsup,\r\n  use g,\r\n  exact \u27e8hg, \u03bb a, @hfiny (g (f a)) a (hg (f a))\u27e9,\r\nend\r\n\r\n-- 4\u00aa demostraci\u00f3n\r\nexample\r\n  (hf : bijective f)\r\n  : tiene_inversa f :=\r\nbegin\r\n  rcases hf with \u27e8hfiny, hfsup\u27e9,\r\n  choose g hg using hfsup,\r\n  use [g, \u27e8hg, \u03bb a, @hfiny (g (f a)) a (hg (f a))\u27e9],\r\nend\r\n\r\n-- 5\u00aa demostraci\u00f3n\r\nexample\r\n  (hf : bijective f)\r\n  : tiene_inversa f :=\r\nbegin\r\n  cases (bijective_iff_has_inverse.mp hf) with g hg,\r\n  by tidy,\r\nend\r\n<\/pre>\n<p>Se puede interactuar con la prueba anterior en <a href=\"https:\/\/leanprover-community.github.io\/lean-web-editor\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus\/main\/src\/Las_funciones_biyectivas_tienen_inversa.lean\" rel=\"noopener noreferrer\" target=\"_blank\">esta sesi\u00f3n con Lean<\/a>.<\/p>\n<p>En los comentarios se pueden escribir otras soluciones, escribiendo el c\u00f3digo entre una l\u00ednea con &#60;pre lang=&quot;lean&quot;&#62; y otra con &#60;\/pre&#62;<br \/>\n[\/expand]<\/p>\n<p>[expand title=\u00bbSoluciones con Isabelle\/HOL\u00bb]<\/p>\n<pre lang=\"isar\">\r\ntheory Las_funciones_biyectivas_tienen_inversa\r\nimports Main\r\nbegin\r\n\r\ndefinition inversa :: \"('a \u21d2 'b) \u21d2 ('b \u21d2 'a) \u21d2 bool\" where\r\n  \"inversa f g \u27f7 (\u2200 x. (g \u2218 f) x = x) \u2227 (\u2200 y. (f \u2218 g) y = y)\"\r\n\r\ndefinition tiene_inversa :: \"('a \u21d2 'b) \u21d2 bool\" where\r\n  \"tiene_inversa f \u27f7 (\u2203 g. inversa f g)\"\r\n\r\n(* 1\u00aa demostraci\u00f3n *)\r\nlemma\r\n  assumes \"bij f\"\r\n  shows   \"tiene_inversa f\"\r\nproof -\r\n  have \"surj f\"\r\n    using assms by (rule bij_is_surj)\r\n  then obtain g where hg : \"\u2200y. f (g y) = y\"\r\n    by (metis surjD)\r\n  have \"inversa f g\"\r\n  proof (unfold inversa_def; intro conjI)\r\n    show \"\u2200x. (g \u2218 f) x = x\"\r\n    proof (rule allI)\r\n      fix x\r\n      have \"inj f\"\r\n        using \u2039bij f\u203a by (rule bij_is_inj)\r\n      then show \"(g \u2218 f) x = x\"\r\n      proof (rule injD)\r\n        have \"f ((g \u2218 f) x) = f (g (f x))\"\r\n          by simp\r\n        also have \"\u2026 = f x\"\r\n          by (simp add: hg)\r\n        finally show \"f ((g \u2218 f) x) = f x\"\r\n          by this\r\n      qed\r\n    qed\r\n    next\r\n      show \"\u2200y. (f \u2218 g) y = y\"\r\n        by (simp add: hg)\r\n  qed\r\n  then show \"tiene_inversa f\"\r\n    using tiene_inversa_def by blast\r\nqed\r\n\r\n(* 2\u00aa demostraci\u00f3n *)\r\nlemma\r\n  assumes \"bij f\"\r\n  shows   \"tiene_inversa f\"\r\nproof -\r\n  have \"surj f\"\r\n    using assms by (rule bij_is_surj)\r\n  then obtain g where hg : \"\u2200y. f (g y) = y\"\r\n    by (metis surjD)\r\n  have \"inversa f g\"\r\n  proof (unfold inversa_def; intro conjI)\r\n    show \"\u2200x. (g \u2218 f) x = x\"\r\n    proof (rule allI)\r\n      fix x\r\n      have \"inj f\"\r\n        using \u2039bij f\u203a by (rule bij_is_inj)\r\n      then show \"(g \u2218 f) x = x\"\r\n      proof (rule injD)\r\n        have \"f ((g \u2218 f) x) = f (g (f x))\"\r\n          by simp\r\n        also have \"\u2026 = f x\"\r\n          by (simp add: hg)\r\n        finally show \"f ((g \u2218 f) x) = f x\"\r\n          by this\r\n      qed\r\n    qed\r\n  next\r\n    show \"\u2200y. (f \u2218 g) y = y\"\r\n      by (simp add: hg)\r\n  qed\r\n  then show \"tiene_inversa f\"\r\n    using tiene_inversa_def by auto\r\nqed\r\n\r\n(* 3\u00aa demostraci\u00f3n *)\r\nlemma\r\n  assumes \"bij f\"\r\n  shows   \"tiene_inversa f\"\r\nproof -\r\n  have \"inversa f (inv f)\"\r\n  proof (unfold inversa_def; intro conjI)\r\n    show \"\u2200x. (inv f \u2218 f) x = x\"\r\n      by (simp add: \u2039bij f\u203a bij_is_inj)\r\n  next\r\n    show \"\u2200y. (f \u2218 inv f) y = y\"\r\n      by (simp add: \u2039bij f\u203a bij_is_surj surj_f_inv_f)\r\n  qed\r\n  then show \"tiene_inversa f\"\r\n    using tiene_inversa_def by auto\r\nqed\r\n\r\nend\r\n<\/pre>\n<p>En los comentarios se pueden escribir otras soluciones, escribiendo el c\u00f3digo entre una l\u00ednea con &#60;pre lang=&quot;isar&quot;&#62; y otra con &#60;\/pre&#62;<br \/>\n[\/expand]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>En Lean se puede definir que g es una inversa de f por def inversa (f : X \u2192 Y) (g : Y \u2192 X) := (\u2200 x, (g \u2218 f) x = x) \u2227 (\u2200 y, (f \u2218 g) y = y) y que f tiene inversa por def tiene_inversa (f : X \u2192 Y) := \u2203 g, inversa g f Demostrar que si la funci\u00f3n f es biyectiva, entonces f tiene inversa. Para ello, completar la siguiente teor\u00eda de Lean: import tactic open function variables {X Y : Type*} variable (f : X \u2192 Y) def inversa (f : X \u2192 Y) (g : Y \u2192 X) := (\u2200 x, (g \u2218 f) x = x) \u2227 (\u2200 y, (f \u2218 g) y&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[17],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/639"}],"collection":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/comments?post=639"}],"version-history":[{"count":2,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/639\/revisions"}],"predecessor-version":[{"id":648,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/639\/revisions\/648"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}