        {"id":1929,"date":"2024-01-15T06:00:10","date_gmt":"2024-01-15T04:00:10","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=1929"},"modified":"2024-01-16T13:38:16","modified_gmt":"2024-01-16T11:38:16","slug":"15-ene-24","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/15-ene-24\/","title":{"rendered":"En \u211d, |x + y| \u2264 |x| + |y|"},"content":{"rendered":"\n<p>Demostrar con Lean4 que en &#92;(\u211d&#92;),<br \/>\n&#92;[ |x + y| \u2264 |x| + |y| &#92;]<\/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 : |x + y| \u2264 |x| + |y| :=\r\nby sorry\r\n<\/pre>\n<p><!--more--><\/p>\n<p><b>Demostraci\u00f3n en lenguaje natural<\/b><\/p>\n<p>Se usar\u00e1n los siguientes lemas<br \/>\n&#92;begin{align}<br \/>\n    &amp;(\u2200 x \u2208 \u211d)[0 \u2264 x \u2192 |x| = x]                          &#92;tag{L1} &#92;&#92;<br \/>\n    &amp;(\u2200 a, b, c, d \u2208 \u211d)[a \u2264 b \u2227 c \u2264 d \u2192 a + c \u2264 b + d]   &#92;tag{L2} &#92;&#92;<br \/>\n    &amp;(\u2200 x \u2208 \u211d)[x \u2264 |x|]                                  &#92;tag{L3} &#92;&#92;<br \/>\n    &amp;(\u2200 x \u2208 \u211d)[x &lt; 0 \u2192 |x| = -x]                         &#92;tag{L4} &#92;&#92;<br \/>\n    &amp;(\u2200 x, y \u2208 \u211d)[-(x + y) = -x + -y]                    &#92;tag{L5} &#92;&#92;<br \/>\n    &amp;(\u2200 x \u2208 \u211d)[-x \u2264 |x|]                                 &#92;tag{L6}<br \/>\n&#92;end{align}<\/p>\n<p>Se demostrar\u00e1 por casos seg\u00fan &#92;(x + y \u2265 0&#92;):<\/p>\n<p>Primer caso: Supongamos que &#92;(x + y \u2265 0&#92;). Entonces,<br \/>\n&#92;begin{align}<br \/>\n   |x + y| &amp;= x + y        &amp;&amp;&#92;text{[por L1]} &#92;&#92;<br \/>\n           &amp;\u2264 |x| + |y|    &amp;&amp;&#92;text{[por L2 y L3]}<br \/>\n&#92;end{align}<\/p>\n<p>Segundo caso: Supongamos que &#92;(x + y &lt; 0&#92;). Entonces,<br \/>\n&#92;begin{align}<br \/>\n   |x + y| &amp;= -(x + y)     &amp;&amp;&#92;text{[por L4]} &#92;&#92;<br \/>\n           &amp;= -x + -y      &amp;&amp;&#92;text{[por L5]} &#92;&#92;<br \/>\n           &amp;\u2264 |x| + |y|    &amp;&amp;&#92;text{[por L2 y L6]}<br \/>\n&#92;end{align}<\/p>\n<p><b>Demostraciones con Lean4<\/b><\/p>\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 : |x + y| \u2264 |x| + |y| :=\r\nby\r\n  rcases le_or_gt 0 (x + y) with h1 | h2\r\n  \u00b7 -- h1 : 0 \u2264 x + y\r\n    show |x + y| \u2264 |x| + |y|\r\n    calc |x + y| = x + y     := by exact abs_of_nonneg h1\r\n               _ \u2264 |x| + |y| := add_le_add (le_abs_self x) (le_abs_self y)\r\n  . -- h2 : 0 > x + y\r\n    show |x + y| \u2264 |x| + |y|\r\n    calc |x + y| = -(x + y)  := by exact abs_of_neg h2\r\n               _ = -x + -y   := by exact neg_add x y\r\n               _ \u2264 |x| + |y| := add_le_add (neg_le_abs_self x) (neg_le_abs_self y)\r\n\r\n-- 2\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample : |x + y| \u2264 |x| + |y| := by\r\n  rcases le_or_gt 0 (x + y) with h1 | h2\r\n  \u00b7 -- h1 : 0 \u2264 x + y\r\n    rw [abs_of_nonneg h1]\r\n    -- \u22a2 x + y \u2264 |x| + |y|\r\n    exact add_le_add (le_abs_self x) (le_abs_self y)\r\n  . -- h2 : 0 > x + y\r\n    rw [abs_of_neg h2]\r\n    -- \u22a2 -(x + y) \u2264 |x| + |y|\r\n    calc -(x + y) = -x + -y    := by exact neg_add x y\r\n                _ \u2264 |x| + |y|  := add_le_add (neg_le_abs_self x) (neg_le_abs_self y)\r\n\r\n-- 2\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample : |x + y| \u2264 |x| + |y| := by\r\n  rcases le_or_gt 0 (x + y) with h1 | h2\r\n  \u00b7 -- h1 : 0 \u2264 x + y\r\n    rw [abs_of_nonneg h1]\r\n    -- \u22a2 x + y \u2264 |x| + |y|\r\n    linarith [le_abs_self x, le_abs_self y]\r\n  . -- h2 : 0 > x + y\r\n    rw [abs_of_neg h2]\r\n    -- \u22a2 -(x + y) \u2264 |x| + |y|\r\n    linarith [neg_le_abs_self x, neg_le_abs_self y]\r\n\r\n-- 3\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample : |x + y| \u2264 |x| + |y| :=\r\n  abs_add x y\r\n\r\n-- Lemas usados\r\n-- ============\r\n\r\n-- variable (a b c d : \u211d)\r\n-- #check (abs_add x y : |x + y| \u2264 |x| + |y|)\r\n-- #check (abs_of_neg : x < 0 \u2192 |x| = -x)\r\n-- #check (abs_of_nonneg : 0 \u2264 x \u2192 |x| = x)\r\n-- #check (add_le_add : a \u2264 b \u2192 c \u2264 d \u2192 a + c \u2264 b + d)\r\n-- #check (le_abs_self a : a \u2264 |a|)\r\n-- #check (le_or_gt x y : x \u2264 y \u2228 x > y)\r\n-- #check (neg_add x y : -(x + y) = -x + -y)\r\n-- #check (neg_le_abs_self x : -x \u2264 |x|)\r\n<\/pre>\n<p><b>Demostraciones interactivas<\/b><\/p>\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\/Desigualdad_triangular_para_valor_absoluto.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. 38.<\/li>\n<\/ul>\n<p><b>En Isabelle\/HOL<\/b><\/p>\n<pre lang=\"isar\">\r\ntheory Desigualdad_triangular_para_valor_absoluto\r\nimports Main HOL.Real\r\nbegin\r\n\r\n(* 1\u00aa demostraci\u00f3n *)\r\nlemma \r\n    fixes x y :: real\r\n    shows \"\u00a6x + y\u00a6 \u2264 \u00a6x\u00a6 + \u00a6y\u00a6\" \r\nproof -\r\n  { assume h1: \"0 \u2264 x + y\"\r\n    then have \"\u00a6x + y\u00a6 = x + y\"\r\n      by simp\r\n    also have \"... \u2264 \u00a6x\u00a6 + \u00a6y\u00a6\"\r\n      by simp\r\n    finally have \"\u00a6x + y\u00a6 \u2264 \u00a6x\u00a6 + \u00a6y\u00a6\" . }\r\n  moreover\r\n  { assume h2: \"0 > x + y\"\r\n    then have \"\u00a6x + y\u00a6 = -(x + y)\" \r\n      by simp\r\n    also have \"... = -x + -y\" \r\n      by simp\r\n    also have \"... \u2264 \u00a6x\u00a6 + \u00a6y\u00a6\" \r\n      by simp\r\n    finally have \"\u00a6x + y\u00a6 \u2264 \u00a6x\u00a6 + \u00a6y\u00a6\" . }\r\n  ultimately show ?thesis \r\n    by simp\r\nqed\r\n\r\n(* 2\u00aa demostraci\u00f3n *)\r\nlemma \r\n    fixes x y :: real\r\n    shows \"\u00a6x + y\u00a6 \u2264 \u00a6x\u00a6 + \u00a6y\u00a6\" \r\nby (rule abs_triangle_ineq)\r\n\r\n(* 3\u00aa demostraci\u00f3n *)\r\nlemma \r\n    fixes x y :: real\r\n    shows \"\u00a6x + y\u00a6 \u2264 \u00a6x\u00a6 + \u00a6y\u00a6\" \r\nby simp\r\n\r\nend\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Demostrar con Lean4 que en &#92;(\u211d&#92;), &#92;[ |x + y| \u2264 |x| + |y| &#92;] Para ello, completar la siguiente teor\u00eda de Lean4: import Mathlib.Data.Real.Basic variable {x y : \u211d} example : |x + y| \u2264 |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\/1929"}],"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=1929"}],"version-history":[{"count":11,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/1929\/revisions"}],"predecessor-version":[{"id":1952,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/1929\/revisions\/1952"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=1929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=1929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=1929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}