        {"id":1957,"date":"2024-01-22T06:00:46","date_gmt":"2024-01-22T04:00:46","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=1957"},"modified":"2024-01-17T13:56:58","modified_gmt":"2024-01-17T11:56:58","slug":"22-ene-24","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/22-ene-24\/","title":{"rendered":"En \u211d, x\u00b2 = y\u00b2 \u2192 x = y \u2228 x = -y"},"content":{"rendered":"\n<p>Demostrar con Lean4 que en \\(\u211d\\),<br \/>\n\\[x\u00b2 = y\u00b2 \u2192 x = y \u2228 x = -y\\]<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\r\nimport Mathlib.Data.Real.Basic\r\nvariable (x y : \u211d)\r\n\r\nexample\r\n  (h : x^2 = y^2)\r\n  : x = y \u2228 x = -y :=\r\nby sorry\r\n<\/pre>\n<p><!--more--><\/p>\n<h2>1. Demostraci\u00f3n en lenguaje natural<\/h2>\n<p>Usaremos los siguientes lemas<br \/>\n\\begin{align}<br \/>\n   &#038;(\u2200 x \u2208 \u211d)[x &#8211; x = 0]                                           \\tag{L1} \\\\<br \/>\n   &#038;(\u2200 x, y \u2208 \u211d)[xy = 0 \u2192 x = 0 \u2228 y = 0]                           \\tag{L2} \\\\<br \/>\n   &#038;(\u2200 x, y \u2208 \u211d)[x &#8211; y = 0 \u2194 x = y]                                \\tag{L3} \\\\<br \/>\n   &#038;(\u2200 x, y \u2208 \u211d)[x + y = 0 \u2192 x = -y]                               \\tag{L4}<br \/>\n\\end{align}<\/p>\n<p>Se tiene que<br \/>\n\\begin{align}<br \/>\n   (x &#8211; y)(x + y) &#038;= x\u00b2 &#8211; y\u00b2    \\\\<br \/>\n                  &#038;= y\u00b2 &#8211; y\u00b2    &#038;&#038;\\text{[por la hip\u00f3tesis]} \\\\<br \/>\n                  &#038;= 0          &#038;&#038;\\text{[por L1]}<br \/>\n\\end{align}<br \/>\ny, por el lema L2, se tiene que<br \/>\n\\[ x &#8211; y = 0 \u2228 x + y = 0 \\]<\/p>\n<p>Acabaremos la demostraci\u00f3n por casos.<\/p>\n<p>Primer caso:<br \/>\n\\begin{align}<br \/>\n  x &#8211; y = 0 &#038;\u27f9 x = y             &#038;&#038;\\text{[por L3]} \\\\<br \/>\n            &#038;\u27f9 x = y \u2228 x = -y<br \/>\n\\end{align}<\/p>\n<p>Segundo caso:<br \/>\n\\begin{align}<br \/>\n  x + y = 0 &#038;\u27f9 x = -y            &#038;&#038;\\text{[por L4]} \\\\<br \/>\n            &#038;\u27f9 x = y \u2228 x = -y<br \/>\n\\end{align}<\/p>\n<h2>2. Demostraciones con Lean4<\/h2>\n<pre lang=\"lean\">\r\nimport Mathlib.Data.Real.Basic\r\nvariable (x y : \u211d)\r\n\r\n-- 1\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample\r\n  (h : x^2 = y^2)\r\n  : x = y \u2228 x = -y :=\r\nby\r\n  have h1 : (x - y) * (x + y) = 0 := by\r\n    calc (x - y) * (x + y) = x^2 - y^2 := by ring\r\n                         _ = y^2 - y^2 := by rw [h]\r\n                         _ = 0         := sub_self (y ^ 2)\r\n  have h2 : x - y = 0 \u2228 x + y = 0 := by\r\n    apply eq_zero_or_eq_zero_of_mul_eq_zero h1\r\n  rcases h2 with h3 | h4\r\n  . -- h3 : x - y = 0\r\n    left\r\n    -- \u22a2 x = y\r\n    exact sub_eq_zero.mp h3\r\n  . -- h4 : x + y = 0\r\n    right\r\n    -- \u22a2 x = -y\r\n    exact eq_neg_of_add_eq_zero_left h4\r\n\r\n-- 2\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample\r\n  (h : x^2 = y^2)\r\n  : x = y \u2228 x = -y :=\r\nby\r\n  have h1 : (x - y) * (x + y) = 0 := by nlinarith\r\n  have h2 : x - y = 0 \u2228 x + y = 0 := by aesop\r\n  rcases h2 with h3 | h4\r\n  . -- h3 : x - y = 0\r\n    left\r\n    -- \u22a2 x = y\r\n    linarith\r\n  . -- h4 : x + y = 0\r\n    right\r\n    -- \u22a2 x = -y\r\n    linarith\r\n\r\n-- 2\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample\r\n  (h : x^2 = y^2)\r\n  : x = y \u2228 x = -y :=\r\nsq_eq_sq_iff_eq_or_eq_neg.mp h\r\n\r\n-- Lemas usados\r\n-- ============\r\n\r\n-- #check (eq_neg_of_add_eq_zero_left : x + y = 0 \u2192 x = -y)\r\n-- #check (eq_zero_or_eq_zero_of_mul_eq_zero : x * y = 0 \u2192 x = 0 \u2228 y = 0)\r\n-- #check (sq_eq_sq_iff_eq_or_eq_neg : x ^ 2 = y ^ 2 \u2194 x = y \u2228 x = -y)\r\n-- #check (sub_eq_zero : x - y = 0 \u2194 x = y)\r\n-- #check (sub_self x : x - x = 0)\r\n<\/pre>\n<h3>Demostraciones interactivas<\/h3>\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\/Cuadrado_igual_a_cuadrado.lean\" rel=\"noopener noreferrer\" target=\"_blank\">Lean 4 Web<\/a>.<\/p>\n<h3>Referencias<\/h3>\n<ul>\n<li> J. Avigad y P. Massot. <a href=\"https:\/\/bit.ly\/3U4UjBk\">Mathematics in Lean<\/a>, p. 39.<\/li>\n<\/ul>\n<h2>3. Demostraciones con Isabelle\/HOL<\/h2>\n<pre lang=\"isar\">\r\ntheory Cuadrado_igual_a_uno\r\n  imports Main HOL.Real\r\nbegin\r\n\r\n(* 1\u00aa demostraci\u00f3n *)\r\nlemma\r\n  fixes x :: real\r\n  assumes \"x^2 = 1\"\r\n  shows \"x = 1 \u2228 x = -1\"\r\nproof -\r\n  have \"(x - 1) * (x + 1) = x^2 - 1\"\r\n    by algebra\r\n  also have \"... = 0\"\r\n    using assms by simp\r\n  finally have \"(x - 1) * (x + 1) = 0\" .\r\n  moreover\r\n  { assume \"(x - 1) = 0\"\r\n    then have \"x = 1\"\r\n      by simp }\r\n  moreover\r\n  { assume \"(x + 1) = 0\"\r\n    then have \"x = -1\"\r\n      by simp }\r\n  ultimately show \"x = 1 \u2228 x = -1\"\r\n    by auto\r\nqed\r\n\r\n(* 2\u00aa demostraci\u00f3n *)\r\nlemma\r\n  fixes x :: real\r\n  assumes \"x^2 = 1\"\r\n  shows \"x = 1 \u2228 x = -1\"\r\nproof -\r\n  have \"(x - 1) * (x + 1) = x^2 - 1\"\r\n    by algebra\r\n  also have \"... = 0\"\r\n    using assms by simp\r\n  finally have \"(x - 1) * (x + 1) = 0\" .\r\n  then show \"x = 1 \u2228 x = -1\"\r\n    by auto\r\nqed\r\n\r\n(* 3\u00aa demostraci\u00f3n *)\r\nlemma\r\n  fixes x :: real\r\n  assumes \"x^2 = 1\"\r\n  shows \"x = 1 \u2228 x = -1\"\r\nproof -\r\n  have \"(x - 1) * (x + 1) = 0\"\r\n  proof -\r\n    have \"(x - 1) * (x + 1) = x^2 - 1\" by algebra\r\n    also have \"\u2026 = 0\" by (simp add: assms)\r\n    finally show ?thesis .\r\n  qed\r\n  then show \"x = 1 \u2228 x = -1\"\r\n    by auto\r\nqed\r\n\r\n(* 4\u00aa demostraci\u00f3n *)\r\nlemma\r\n  fixes x :: real\r\n  assumes \"x^2 = 1\"\r\n  shows \"x = 1 \u2228 x = -1\"\r\nusing assms power2_eq_1_iff by blast\r\n\r\nend\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Demostrar con Lean4 que en \\(\u211d\\), \\[x\u00b2 = y\u00b2 \u2192 x = y \u2228 x = -y\\] Para ello, completar la siguiente teor\u00eda de Lean4: import Mathlib.Data.Real.Basic variable (x y : \u211d) example (h : x^2 = y^2) : x = y \u2228 x = -y := 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":"","_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":[1],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/1957"}],"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=1957"}],"version-history":[{"count":4,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/1957\/revisions"}],"predecessor-version":[{"id":1968,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/1957\/revisions\/1968"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=1957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=1957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=1957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}