{"id":8002,"date":"2023-08-12T12:33:17","date_gmt":"2023-08-12T10:33:17","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/?p=8002"},"modified":"2023-08-12T12:38:23","modified_gmt":"2023-08-12T10:38:23","slug":"12-ago-23","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/12-ago-23\/","title":{"rendered":"La semana en Calculemus (12 de agosto de 2023)"},"content":{"rendered":"\n<p>Esta semana he publicado en <a href=\"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/\">Calculemus<\/a> las demostraciones con Lean4 de las siguientes propiedades:<\/p>\n<ul>\n<li><a href=\"#ej1\">1. Si R es un anillo y a, b \u2208 R tales que a+b=0, entonces -a=b<\/a><\/li>\n<li><a href=\"#ej2\">2. Si R es un anillo y a, b \u2208 R tales que a+b=0, entonces a=-b<\/a><\/li>\n<li><a href=\"#ej3\">3. Si R es un anillo, entonces -0 = 0<\/a><\/li>\n<li><a href=\"#ej4\">4. Si R es un anillo y a \u2208 R, entonces -(-a) = a<\/a><\/li>\n<li><a href=\"#ej5\">5. Si R es un anillo y a, b \u2208 R, entonces a &#8211; b = a + -b<\/a><\/li>\n<\/ul>\n<p>A continuaci\u00f3n se muestran las soluciones.<br \/>\n<!--more--><br \/>\n<a name=\"ej1\"><\/a><\/p>\n<h3>1. Si R es un anillo y a, b \u2208 R tales que a+b=0, entonces -a=b<\/h3>\n<p>Demostrar con Lean4 que si &#92;(R&#92;) es un anillo y &#92;(a, b \\in R&#92;) tales que &#92;(a + b = 0&#92;) entonces &#92;(-a = b&#92;).<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport Mathlib.Algebra.Ring.Defs\nimport Mathlib.Tactic\n\nvariable {R : Type _} [Ring R]\nvariable {a b : R}\n\nexample\n  (h : a + b = 0)\n  : -a = b :=\nsorry\n<\/pre>\n<p><b>Demostraciones en lenguaje natural (LN)<\/b><\/p>\n<p><b>1\u00aa demostraci\u00f3n en LN<\/b><\/p>\n<p>Por la siguiente cadena de igualdades<br \/>\n&#92;begin{align}<br \/>\n   -a &amp;= -a + 0          &amp;&amp;&#92;text{[por suma cero]} &#92;&#92;<br \/>\n      &amp;= -a + (a + b)    &amp;&amp;&#92;text{[por hip\u00f3tesis]} &#92;&#92;<br \/>\n      &amp;= b               &amp;&amp;&#92;text{[por cancelativa]}<br \/>\n&#92;end{align}<\/p>\n<p><b>2\u00aa demostraci\u00f3n en LN<\/b><\/p>\n<p>Sumando &#92;(-a&#92;) a ambos lados de la hip\u00f3tesis, se tiene<br \/>\n&#92;[-a + (a + b) = -a + 0&#92;]<br \/>\nEl t\u00e9rmino de la izquierda se reduce a &#92;(b&#92;) (por la cancelativa) y el de la derecha a &#92;(-a&#92;) (por la suma con cero). Por tanto, se tiene<br \/>\n&#92;[b = -a&#92;]<br \/>\nPor la simetr\u00eda de la igualdad, se tiene<br \/>\n&#92;[-a = b&#92;]<\/p>\n<p><b>Demostraciones con Lean4<\/b><\/p>\n<pre lang=\"lean\">\nimport Mathlib.Algebra.Ring.Defs\nimport Mathlib.Tactic\n\nvariable {R : Type _} [Ring R]\nvariable {a b : R}\n\n-- 1\u00aa demostraci\u00f3n (basada en la 1\u00ba en LN)\nexample\n  (h : a + b = 0)\n  : -a = b :=\ncalc\n  -a = -a + 0       := by rw [add_zero]\n   _ = -a + (a + b) := by rw [h]\n   _ = b            := by rw [neg_add_cancel_left]\n\n-- 2\u00aa demostraci\u00f3n (basada en la 1\u00ba en LN)\nexample\n  (h : a + b = 0)\n  : -a = b :=\ncalc\n  -a = -a + 0       := by simp\n   _ = -a + (a + b) := by rw [h]\n   _ = b            := by simp\n\n-- 3\u00aa demostraci\u00f3n (basada en la 2\u00ba en LN)\nexample\n  (h : a + b = 0)\n  : -a = b :=\nby\n  have h1 : -a + (a + b) = -a + 0 := congrArg (HAdd.hAdd (-a)) h\n  have h2 : -a + (a + b) = b := neg_add_cancel_left a b\n  have h3 : -a + 0 = -a := add_zero (-a)\n  rw [h2, h3] at h1\n  exact h1.symm\n\n-- 4\u00aa demostraci\u00f3n (con la librer\u00eda mathlib)\nexample\n  (h : a + b = 0)\n  : -a = b :=\nneg_eq_iff_add_eq_zero.mpr h\n<\/pre>\n<p><b>Demostraciones interactivas<\/b><\/p>\n<p>Se puede interactuar con las demostraciones anteriores en <a href=\"https:\/\/lean.math.hhu.de\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus2\/main\/src\/Opuesto_ig_si_suma_ig_cero.lean\" rel=\"noopener noreferrer\" target=\"_blank\">Lean 4 Web<\/a>.<\/p>\n<p><b>Referencias<\/b><\/p>\n<ul>\n<li> J. Avigad y P. Massot. <a href=\"https:\/\/bit.ly\/3U4UjBk\">Mathematics in Lean<\/a>, p. 11.<\/li>\n<\/ul>\n<p><a name=\"ej2\"><\/a><\/p>\n<h3>2. Si R es un anillo y a, b \u2208 R tales que a+b=0, entonces a=-b<\/h3>\n<p>Demostrar con Lean4 que si &#92;(R&#92;) es un anillo y &#92;(a, b \\in R&#92;) tales que &#92;(a + b = 0&#92;) entonces &#92;(a = -b&#92;).<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport Mathlib.Algebra.Ring.Defs\nimport Mathlib.Tactic\n\nvariable {R : Type _} [Ring R]\nvariable {a b : R}\n\nexample\n  (h : a + b = 0)\n  : a = -b :=\nsorry\n<\/pre>\n<p><b>Demostraci\u00f3n en lenguaje natural<\/b><\/p>\n<p><b>1\u00aa demostraci\u00f3n en LN<\/b><\/p>\n<p>Por la siguiente cadena de igualdades<br \/>\n&#92;begin{align}<br \/>\n   a &amp;= (a + b) + -b    &amp;&amp;&#92;text{[por la concelativa]} &#92;&#92;<br \/>\n     &amp;= 0 + -b          &amp;&amp;&#92;text{[por la hip\u00f3tesis]} &#92;&#92;<br \/>\n     &amp;= -b              &amp;&amp;&#92;text{[por la suma con cero]}<br \/>\n&#92;end{align}<\/p>\n<p><b>2\u00aa demostraci\u00f3n en LN<\/b><\/p>\n<p>Sumando &#92;(-a&#92;) a ambos lados de la hip\u00f3tesis, se tiene<br \/>\n&#92;[(a + b) + -b = 0 + -b&#92;]<br \/>\nEl t\u00e9rmino de la izquierda se reduce a &#92;(a&#92;) (por la cancelativa) y el de la derecha a &#92;(-b&#92;) (por la suma con cero). Por tanto, se tiene<br \/>\n&#92;[a = -b&#92;]<\/p>\n<p><b>Demostraciones con Lean4<\/b><\/p>\n<pre lang=\"lean\">\nimport Mathlib.Algebra.Ring.Defs\nimport Mathlib.Tactic\n\nvariable {R : Type _} [Ring R]\nvariable {a b : R}\n\n-- 1\u00aa demostraci\u00f3n (basada en la 1\u00aa en LN)\nexample\n  (h : a + b = 0)\n  : a = -b :=\ncalc\n  a = (a + b) + -b := by rw [add_neg_cancel_right]\n  _ = 0 + -b       := by rw [h]\n  _ = -b           := by rw [zero_add]\n\n-- 2\u00aa demostraci\u00f3n (basada en la 1\u00aa en LN)\nexample\n  (h : a + b = 0)\n  : a = -b :=\ncalc\n  a = (a + b) + -b := by simp\n  _ = 0 + -b       := by rw [h]\n  _ = -b           := by simp\n\n-- 3\u00aa demostraci\u00f3n (basada en la 1\u00aa en LN)\nexample\n  (h : a + b = 0)\n  : a = -b :=\nby\n  have h1 : (a + b) + -b = 0 + -b := by rw [h]\n  have h2 : (a + b) + -b = a := add_neg_cancel_right a b\n  have h3 : 0 + -b = -b := zero_add (-b)\n  rwa [h2, h3] at h1\n\n-- 4\u00aa demostraci\u00f3n\nexample\n  (h : a + b = 0)\n  : a = -b :=\nadd_eq_zero_iff_eq_neg.mp h\n<\/pre>\n<p><b>Demostraciones interactivas<\/b><\/p>\n<p>Se puede interactuar con las demostraciones anteriores en <a href=\"https:\/\/lean.math.hhu.de\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus2\/main\/src\/Ig_opuesto_si_suma_ig_cero.lean\" rel=\"noopener noreferrer\" target=\"_blank\">Lean 4 Web<\/a>.<\/p>\n<p><b>Referencias<\/b><\/p>\n<ul>\n<li> J. Avigad y P. Massot. <a href=\"https:\/\/bit.ly\/3U4UjBk\">Mathematics in Lean<\/a>, p. 11.<\/li>\n<\/ul>\n<p><a name=\"ej3\"><\/a><\/p>\n<h3>3. Si R es un anillo, entonces -0 = 0<\/h3>\n<p>Demostrar con Lean4 que si &#92;(R&#92;) es un anillo, entonces &#92;(-0 = 0&#92;).<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport Mathlib.Algebra.Ring.Defs\nimport Mathlib.Tactic\n\nvariable {R : Type _} [Ring R]\n\nexample : (-0 : R) = 0 :=\nsorry\n<\/pre>\n<p><b>Demostraciones en lenguaje natural (LN)<\/b><\/p>\n<p><b>1\u00aa demostraci\u00f3n en LN<\/b><\/p>\n<p>Por la suma con cero se tiene<br \/>\n&#92;[0 + 0 = 0&#92;]<br \/>\nAplic\u00e1ndole la propiedad<br \/>\n&#92;[&#92;forall a b \u2208 R, a + b = 0 &#92;to -a = b&#92;]<br \/>\nse obtiene<br \/>\n&#92;[-0 = 0&#92;]<\/p>\n<p><b>2\u00aa demostraci\u00f3n en LN<\/b><\/p>\n<p>Puesto que<br \/>\n&#92;[&#92;forall a b \u2208 R, a + b = 0 &#92;to -a = b&#92;]<br \/>\nbasta demostrar que<br \/>\n&#92;[0 + 0 = 0&#92;]<br \/>\nque es cierta por la suma con cero.<\/p>\n<p><b>Demostraciones con Lean4<\/b><\/p>\n<pre lang=\"lean\">\nimport Mathlib.Algebra.Ring.Defs\nimport Mathlib.Tactic\n\nvariable {R : Type _} [Ring R]\n\n-- 1\u00aa demostraci\u00f3n (basada en la 1\u00aa en LN)\nexample : (-0 : R) = 0 :=\nby\n  have h1 : (0 : R) + 0 = 0 := add_zero 0\n  show (-0 : R) = 0\n  exact neg_eq_of_add_eq_zero_left h1\n\n-- 2\u00aa demostraci\u00f3n (basada en la 2\u00aa en LN)\nexample : (-0 : R) = 0 :=\nby\n  apply neg_eq_of_add_eq_zero_left\n  rw [add_zero]\n\n-- 3\u00aa demostraci\u00f3n\nexample : (-0 : R) = 0 :=\n  neg_zero\n\n-- 4\u00aa demostraci\u00f3n\nexample : (-0 : R) = 0 :=\nby simp\n<\/pre>\n<p><b>Demostraciones interactivas<\/b><\/p>\n<p>Se puede interactuar con las demostraciones anteriores en <a href=\"https:\/\/lean.math.hhu.de\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus2\/main\/src\/Opuesto_del_cero.lean\" rel=\"noopener noreferrer\" target=\"_blank\">Lean 4 Web<\/a>.<\/p>\n<p><b>Referencias<\/b><\/p>\n<ul>\n<li> J. Avigad y P. Massot. <a href=\"https:\/\/bit.ly\/3U4UjBk\">Mathematics in Lean<\/a>, p. 11.<\/li>\n<\/ul>\n<p><a name=\"ej4\"><\/a><\/p>\n<h3>4. Si R es un anillo y a \u2208 R, entonces -(-a) = a<\/h3>\n<p>Demostrar con Lean4 que si &#92;(R&#92;) es un anillo y &#92;(a \\in R&#92;), entonces<br \/>\n&#92;(-(-a) = a&#92;).<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport Mathlib.Algebra.Ring.Defs\nimport Mathlib.Tactic\n\nvariable {R : Type _} [Ring R]\nvariable {a : R}\n\nexample : -(-a) = a :=\nsorry\n<\/pre>\n<p><b>Demostraci\u00f3n en lenguaje natural<\/b><\/p>\n<p>Es consecuencia de las siguiente propiedades demostradas en ejercicios anteriores:<br \/>\n&#92;begin{align}<br \/>\n &amp;&#92;forall a &#92; b &#92;in R, a + b = 0 &#92;to -a = b &#92;&#92;<br \/>\n &amp;&#92;forall a &#92;in R, -a + a = 0<br \/>\n&#92;end{align}<\/p>\n<p><b>Demostraciones con Lean4<\/b><\/p>\n<pre lang=\"lean\">\nimport Mathlib.Algebra.Ring.Defs\nimport Mathlib.Tactic\n\nvariable {R : Type _} [Ring R]\nvariable {a : R}\n\n-- 1\u00aa demostraci\u00f3n\nexample : -(-a) = a :=\nby\n  have h1 : -a + a = 0 := add_left_neg a\n  show -(-a) = a\n  exact neg_eq_of_add_eq_zero_right h1\n\n-- 2\u00aa demostraci\u00f3n\nexample : -(-a) = a :=\nby\n  apply neg_eq_of_add_eq_zero_right\n  rw [add_left_neg]\n\n-- 3\u00aa demostraci\u00f3n\nexample : -(-a) = a :=\nneg_neg a\n\n-- 4\u00aa demostraci\u00f3n\nexample : -(-a) = a :=\nby simp\n<\/pre>\n<p><b>Demostraciones interactivas<\/b><\/p>\n<p>Se puede interactuar con las demostraciones anteriores en <a href=\"https:\/\/lean.math.hhu.de\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus2\/main\/src\/Opuesto_del_opuesto.lean\" rel=\"noopener noreferrer\" target=\"_blank\">Lean 4 Web<\/a>.<\/p>\n<p><b>Referencias<\/b><\/p>\n<ul>\n<li> J. Avigad y P. Massot. <a href=\"https:\/\/bit.ly\/3U4UjBk\">Mathematics in Lean<\/a>, p. 11.<\/li>\n<\/ul>\n<p><a name=\"ej5\"><\/a><\/p>\n<h3>5. Si R es un anillo y a, b \u2208 R, entonces a &#8211; b = a + -b<\/h3>\n<p>Demostrar con Lean4 que si &#92;(R&#92;) es un anillo y &#92;(a, b &#92;in R&#92;), entonces<br \/>\n&#92;[a &#8211; b = a + -b&#92;]<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport Mathlib.Algebra.Ring.Defs\n\nvariable {R : Type _} [Ring R]\nvariable (a b : R)\n\nexample : a - b = a + -b :=\nsorry\n<\/pre>\n<p><b>Demostraci\u00f3n en lenguaje natural<\/b><\/p>\n<p>Por la definici\u00f3n de la resta.<\/p>\n<p><b>Demostraciones con Lean4<\/b><\/p>\n<pre lang=\"lean\">\nimport Mathlib.Algebra.Ring.Defs\n\nvariable {R : Type _} [Ring R]\nvariable (a b : R)\n\nexample : a - b = a + -b :=\n-- by exact?\nsub_eq_add_neg a b\n<\/pre>\n<p><b>Demostraciones interactivas<\/b><\/p>\n<p>Se puede interactuar con las demostraciones anteriores en <a href=\"https:\/\/lean.math.hhu.de\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus2\/main\/src\/Resta_igual_suma_opuesto.lean\" rel=\"noopener noreferrer\" target=\"_blank\">Lean 4 Web<\/a>.<\/p>\n<p><b>Referencias<\/b><\/p>\n<ul>\n<li> J. Avigad y P. Massot. <a href=\"https:\/\/bit.ly\/3U4UjBk\">Mathematics in Lean<\/a>, p. 12.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Esta semana he publicado en Calculemus las demostraciones con Lean4 de las siguientes propiedades: 1. Si R es un anillo y a, b \u2208 R tales que a+b=0, entonces -a=b 2. Si R es un anillo y a, b \u2208 R tales que a+b=0, entonces a=-b 3. Si R es un anillo, entonces -0 =&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","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,"footnotes":"","_jetpack_memberships_contains_paid_content":false},"categories":[335],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":false,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/posts\/8002"}],"collection":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/comments?post=8002"}],"version-history":[{"count":2,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/posts\/8002\/revisions"}],"predecessor-version":[{"id":8004,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/posts\/8002\/revisions\/8004"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/media?parent=8002"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/categories?post=8002"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/tags?post=8002"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}