        {"id":624,"date":"2021-08-03T06:00:18","date_gmt":"2021-08-03T04:00:18","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=624"},"modified":"2021-08-03T11:25:53","modified_gmt":"2021-08-03T09:25:53","slug":"las-funciones-inyectivas-tienen-inversa-por-la-izquierda","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/las-funciones-inyectivas-tienen-inversa-por-la-izquierda\/","title":{"rendered":"Las funciones inyectivas tienen inversa por la izquierda"},"content":{"rendered":"<p>En Lean, que g es una inversa por la izquierda de f est\u00e1 definido por<\/p>\n<pre lang=\"text\">\n   left_inverse (g : \u03b2 \u2192 \u03b1) (f : \u03b1 \u2192 \u03b2) : Prop :=\n      \u2200 x, g (f x) = x\n<\/pre>\n<p>y que f tenga inversa por la izquierda est\u00e1 definido por<\/p>\n<pre lang=\"text\">\n   has_left_inverse (f : \u03b1 \u2192 \u03b2) : Prop :=\n      \u2203 finv : \u03b2 \u2192 \u03b1, left_inverse finv f\n<\/pre>\n<p>Finalmente, que f es inyectiva est\u00e1 definido por<\/p>\n<pre lang=\"text\">\n   injective (f : \u03b1 \u2192 \u03b2) : Prop :=\n      \u2200 \u2983x y\u2984, f x = f y \u2192 x = y\n<\/pre>\n<p>Demostrar que si f es una funci\u00f3n inyectiva con dominio no vac\u00edo, entonces f tiene inversa por la izquierda.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/p>\n<pre lang=\"lean\">\nimport tactic\nopen function classical\n\nvariables {\u03b1 \u03b2: Type*}\nvariable  {f : \u03b1 \u2192 \u03b2}\n\n-- 1\u00aa demostraci\u00f3n\nexample\n  [h\u03b1 : nonempty \u03b1]\n  (hf : injective f)\n  : has_left_inverse f :=\nsorry\n<\/pre>\n<p>[expand title=\u00bbSoluciones con Lean\u00bb]<\/p>\n<pre lang=\"lean\">\r\nimport tactic\r\nopen function classical\r\n\r\nvariables {\u03b1 \u03b2: Type*}\r\nvariable  {f : \u03b1 \u2192 \u03b2}\r\n\r\n-- 1\u00aa demostraci\u00f3n\r\nexample\r\n  [h\u03b1 : nonempty \u03b1]\r\n  (hf : injective f)\r\n  : has_left_inverse f :=\r\nbegin\r\n  classical,\r\n  unfold has_left_inverse,\r\n  let g := \u03bb y, if h : \u2203 x, f x = y then some h else choice h\u03b1,\r\n  use g,\r\n  unfold left_inverse,\r\n  intro a,\r\n  have h1 : \u2203 x : \u03b1, f x = f a := Exists.intro a rfl,\r\n  dsimp at *,\r\n  dsimp [g],\r\n  rw dif_pos h1,\r\n  apply hf,\r\n  exact some_spec h1,\r\nend\r\n\r\n-- 2\u00aa demostraci\u00f3n\r\nexample\r\n  [h\u03b1 : nonempty \u03b1]\r\n  (hf : injective f)\r\n  : has_left_inverse f :=\r\nbegin\r\n  classical,\r\n  let g := \u03bb y, if h : \u2203 x, f x = y then some h else choice h\u03b1,\r\n  use g,\r\n  intro a,\r\n  have h1 : \u2203 x : \u03b1, f x = f a := Exists.intro a rfl,\r\n  dsimp [g],\r\n  rw dif_pos h1,\r\n  exact hf (some_spec h1),\r\nend\r\n\r\n-- 3\u00aa demostraci\u00f3n\r\nexample\r\n  [h\u03b1 : nonempty \u03b1]\r\n  (hf : injective f)\r\n  : has_left_inverse f :=\r\nbegin\r\n  unfold has_left_inverse,\r\n  use inv_fun f,\r\n  unfold left_inverse,\r\n  intro x,\r\n  apply hf,\r\n  apply inv_fun_eq,\r\n  use x,\r\nend\r\n\r\n-- 4\u00aa demostraci\u00f3n\r\nexample\r\n  [h\u03b1 : nonempty \u03b1]\r\n  (hf : injective f)\r\n  : has_left_inverse f :=\r\nbegin\r\n  use inv_fun f,\r\n  intro x,\r\n  apply hf,\r\n  apply inv_fun_eq,\r\n  use x,\r\nend\r\n\r\n-- 5\u00aa demostraci\u00f3n\r\nexample\r\n  [h\u03b1 : nonempty \u03b1]\r\n  (hf : injective f)\r\n  : has_left_inverse f :=\r\n\u27e8inv_fun f, left_inverse_inv_fun hf\u27e9\r\n\r\n-- 6\u00aa demostraci\u00f3n\r\nexample\r\n  [h\u03b1 : nonempty \u03b1]\r\n  (hf : injective f)\r\n  : has_left_inverse f :=\r\ninjective.has_left_inverse hf\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_inyectivas_tienen_inversa_por_la_izquierda.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_inyectivas_tienen_inversa_por_la_izquierda\r\nimports Main\r\nbegin\r\n\r\ndefinition tiene_inversa_izq :: \"('a \u21d2 'b) \u21d2 bool\" where\r\n  \"tiene_inversa_izq f \u27f7 (\u2203g. \u2200x. g (f x) = x)\"\r\n\r\n(* 1\u00aa demostraci\u00f3n *)\r\nlemma\r\n  assumes \"inj f\"\r\n  shows   \"tiene_inversa_izq f\"\r\nproof (unfold tiene_inversa_izq_def)\r\n  let ?g = \"(\u03bby. SOME x. f x = y)\"\r\n  have \"\u2200x. ?g (f x) = x\"\r\n  proof (rule allI)\r\n    fix a\r\n    have \"\u2203x. f x = f a\"\r\n      by auto\r\n    then have \"f (?g (f a)) = f a\"\r\n      by (rule someI_ex)\r\n    then show \"?g (f a) = a\"\r\n      using assms\r\n      by (simp only: injD)\r\n  qed\r\n  then show \"(\u2203g. \u2200x. g (f x) = x)\"\r\n    by (simp only: exI)\r\nqed\r\n\r\n(* 2\u00aa demostraci\u00f3n *)\r\nlemma\r\n  assumes \"inj f\"\r\n  shows   \"tiene_inversa_izq f\"\r\nproof (unfold tiene_inversa_izq_def)\r\n  have \"\u2200x. inv f (f x) = x\"\r\n  proof (rule allI)\r\n    fix x\r\n    show \"inv f (f x) = x\"\r\n      using assms by (simp only: inv_f_f)\r\n  qed\r\n  then show \"(\u2203g. \u2200x. g (f x) = x)\"\r\n    by (simp only: exI)\r\nqed\r\n\r\n(* 3\u00aa demostraci\u00f3n *)\r\nlemma\r\n  assumes \"inj f\"\r\n  shows   \"tiene_inversa_izq f\"\r\nproof (unfold tiene_inversa_izq_def)\r\n  have \"\u2200x. inv f (f x) = x\"\r\n    by (simp add: assms)\r\n  then show \"(\u2203g. \u2200x. g (f x) = x)\"\r\n    by (simp only: exI)\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, que g es una inversa por la izquierda de f est\u00e1 definido por left_inverse (g : \u03b2 \u2192 \u03b1) (f : \u03b1 \u2192 \u03b2) : Prop := \u2200 x, g (f x) = x y que f tenga inversa por la izquierda est\u00e1 definido por has_left_inverse (f : \u03b1 \u2192 \u03b2) : Prop := \u2203 finv : \u03b2 \u2192 \u03b1, left_inverse finv f Finalmente, que f es inyectiva est\u00e1 definido por injective (f : \u03b1 \u2192 \u03b2) : Prop := \u2200 \u2983x y\u2984, f x = f y \u2192 x = y Demostrar que si f es una funci\u00f3n inyectiva con dominio no vac\u00edo, entonces f tiene inversa por la izquierda. Para ello, completar la siguiente teor\u00eda de Lean: import tactic open function&#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\/624"}],"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=624"}],"version-history":[{"count":2,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/624\/revisions"}],"predecessor-version":[{"id":628,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/624\/revisions\/628"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}