        {"id":2459,"date":"2024-05-08T06:00:27","date_gmt":"2024-05-08T04:00:27","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=2459"},"modified":"2024-05-07T18:28:45","modified_gmt":"2024-05-07T16:28:45","slug":"08-may-24","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/08-may-24\/","title":{"rendered":"Unicidad de inversos en monoides"},"content":{"rendered":"\n<p>Demostrar con Lean4 que si &#92;(M&#92;) es un monoide conmutativo y &#92;(x, y, z \u2208 M&#92;) tales que &#92;(x\u00b7y = 1&#92;) y &#92;(x\u00b7z = 1&#92;), entonces &#92;(y = z&#92;).<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport Mathlib.Algebra.Group.Basic\n\nvariable {M : Type} [CommMonoid M]\nvariable {x y z : M}\n\nexample\n  (hy : x * y = 1)\n  (hz : x * z = 1)\n  : y = z :=\nby sorry\n<\/pre>\n<p><!--more--><\/p>\n<h2>1. Demostraci\u00f3n en lenguaje natural<\/h2>\n<p>Por la siguiente cadena de igualdades<br \/>\n&#92;begin{align}<br \/>\n   y &amp;= 1\u00b7y          &amp;&amp;&#92;text{[por neutro a la izquierda]} &#92;&#92;<br \/>\n     &amp;= (x\u00b7z)\u00b7y      &amp;&amp;&#92;text{[por hip\u00f3tesis]} &#92;&#92;<br \/>\n     &amp;= (z\u00b7x)\u00b7y      &amp;&amp;&#92;text{[por la conmutativa]} &#92;&#92;<br \/>\n     &amp;= z\u00b7(x\u00b7y)      &amp;&amp;&#92;text{[por la asociativa]} &#92;&#92;<br \/>\n     &amp;= z\u00b71          &amp;&amp;&#92;text{[por hip\u00f3tesis]} &#92;&#92;<br \/>\n     &amp;= z            &amp;&amp;&#92;text{[por neutro a la derecha]}<br \/>\n&#92;end{align}<\/p>\n<h2>2. Demostraciones con Lean4<\/h2>\n<pre lang=\"lean\">\nimport Mathlib.Algebra.Group.Basic\n\nvariable {M : Type} [CommMonoid M]\nvariable {x y z : M}\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hy : x * y = 1)\n  (hz : x * z = 1)\n  : y = z :=\ncalc y = 1 * y       := (one_mul y).symm\n     _ = (x * z) * y := congrArg (. * y) hz.symm\n     _ = (z * x) * y := congrArg (. * y) (mul_comm x z)\n     _ = z * (x * y) := mul_assoc z x y\n     _ = z * 1       := congrArg (z * .) hy\n     _ = z           := mul_one z\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hy : x * y = 1)\n  (hz : x * z = 1)\n  : y = z :=\ncalc y = 1 * y     := by simp only [one_mul]\n   _ = (x * z) * y := by simp only [hz]\n   _ = (z * x) * y := by simp only [mul_comm]\n   _ = z * (x * y) := by simp only [mul_assoc]\n   _ = z * 1       := by simp only [hy]\n   _ = z           := by simp only [mul_one]\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hy : x * y = 1)\n  (hz : x * z = 1)\n  : y = z :=\ncalc y = 1 * y     := by simp\n   _ = (x * z) * y := by simp [hz]\n   _ = (z * x) * y := by simp [mul_comm]\n   _ = z * (x * y) := by simp [mul_assoc]\n   _ = z * 1       := by simp [hy]\n   _ = z           := by simp\n\n-- 4\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hy : x * y = 1)\n  (hz : x * z = 1)\n  : y = z :=\nby\n  apply left_inv_eq_right_inv _ hz\n  -- \u22a2 y * x = 1\n  rw [mul_comm]\n  -- \u22a2 x * y = 1\n  exact hy\n\n-- 5\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hy : x * y = 1)\n  (hz : x * z = 1)\n  : y = z :=\ninv_unique hy hz\n\n-- Lemas usados\n-- ============\n\n-- #check (inv_unique : x * y = 1 \u2192 x * z = 1 \u2192 y = z)\n-- #check (left_inv_eq_right_inv : y * x = 1 \u2192 x * z = 1 \u2192 y = z)\n-- #check (mul_assoc x y z : (x * y) * z = x * (y * z))\n-- #check (mul_comm x y : x * y = y * x)\n-- #check (mul_one x : x * 1 = x)\n-- #check (one_mul x : 1 * x = x)\n<\/pre>\n<p>Se puede interactuar con las demostraciones anteriores en <a href=\"https:\/\/live.lean-lang.org\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus2\/main\/src\/Unicidad_de_inversos_en_monoides.lean\">Lean 4 Web<\/a>.<\/p>\n<h2>3. Demostraciones con Isabelle\/HOL<\/h2>\n<pre lang=\"isar\">\ntheory Unicidad_de_inversos_en_monoides\nimports Main\nbegin\n\ncontext comm_monoid\nbegin\n\n(* 1\u00aa demostraci\u00f3n *)\n\nlemma\n  assumes \"x * y = 1\"\n          \"x * z = 1\"\n  shows \"y = z\"\nproof -\n  have \"y = 1 * y\"            by (simp only: left_neutral)\n  also have \"\u2026 = (x * z) * y\" by (simp only: \u2039x * z = 1\u203a)\n  also have \"\u2026 = (z * x) * y\" by (simp only: commute)\n  also have \"\u2026 = z * (x * y)\" by (simp only: assoc)\n  also have \"\u2026 = z * 1\"       by (simp only: \u2039x * y = 1\u203a)\n  also have \"\u2026 = z\"           by (simp only: right_neutral)\n  finally show \"y = z\"        by this\nqed\n\n(* 2\u00aa demostraci\u00f3n *)\n\nlemma\n  assumes \"x * y = 1\"\n          \"x * z = 1\"\n  shows \"y = z\"\nproof -\n  have \"y = 1 * y\"            by simp\n  also have \"\u2026 = (x * z) * y\" using assms(2) by simp\n  also have \"\u2026 = (z * x) * y\" by simp\n  also have \"\u2026 = z * (x * y)\" by simp\n  also have \"\u2026 = z * 1\"       using assms(1) by simp\n  also have \"\u2026 = z\"           by simp\n  finally show \"y = z\"        by this\nqed\n\n(* 3\u00aa demostraci\u00f3n *)\n\nlemma\n  assumes \"x * y = 1\"\n          \"x * z = 1\"\n  shows \"y = z\"\n  using assms\n  by auto\n\nend\n\nend\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Demostrar con Lean4 que si &#92;(M&#92;) es un monoide conmutativo y &#92;(x, y, z \u2208 M&#92;) tales que &#92;(x\u00b7y = 1&#92;) y &#92;(x\u00b7z = 1&#92;), entonces &#92;(y = z&#92;). Para ello, completar la siguiente teor\u00eda de Lean4: import Mathlib.Algebra.Group.Basic variable {M : Type} [CommMonoid M] variable {x y z : M} example (hy : x * y = 1) (hz : x * z = 1) : y = z := by sorry<\/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":"default","_kad_post_title":"default","_kad_post_layout":"default","_kad_post_sidebar_id":"","_kad_post_content_style":"default","_kad_post_vertical_padding":"default","_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":[9],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2459"}],"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=2459"}],"version-history":[{"count":1,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2459\/revisions"}],"predecessor-version":[{"id":2460,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2459\/revisions\/2460"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=2459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=2459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=2459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}