        {"id":1648,"date":"2023-10-10T06:00:32","date_gmt":"2023-10-10T04:00:32","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=1648"},"modified":"2023-10-10T12:07:40","modified_gmt":"2023-10-10T10:07:40","slug":"10-oct-23","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/10-oct-23\/","title":{"rendered":"La suma de dos funciones mon\u00f3tonas es mon\u00f3tona"},"content":{"rendered":"<p>Demostrar con Lean4 que la suma de dos funciones mon\u00f3tonas es mon\u00f3tona.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport Mathlib.Data.Real.Basic\n\nvariable (f g : \u211d \u2192 \u211d)\n\nexample\n  (mf : Monotone f)\n  (mg : Monotone g)\n  : Monotone (f + g) :=\nby sorry\n<\/pre>\n<p><!--more--><\/p>\n<p><b>Demostraci\u00f3n en lenguaje natural<\/b><\/p>\n<p><br \/>\nSe usar\u00e1 el siguiente lema:<br \/>\n&#92;[ &#92;{a \u2264 b, c \u2264 d&#92;} \u22a2 a + c \u2264 b + d &#92;tag{L1} &#92;]<\/p>\n<p>Supongamos que &#92;(f&#92;) y &#92;(g&#92;) son mon\u00f3tonas y teneno que demostrar que &#92;(f+g&#92;) tambi\u00e9n lo es; que<br \/>\n&#92;[ (\u2200 a,&#92; b &#92;in \u211d) [a \u2264 b \u2192 (f + g)(a) \u2264 (f + g)(b)] &#92;]<br \/>\nSean &#92;(a, b \u2208 \u211d&#92;) tales que<br \/>\n&#92;[ a \u2264 b &#92;tag{1} &#92;]<br \/>\nEntonces, por ser &#92;(f&#92;) y &#92;(g&#92;) mon\u00f3tonas se tiene<br \/>\n&#92;begin{align}<br \/>\n   f(a) &amp;\u2264 f(b) &#92;tag{2} &#92;&#92;<br \/>\n   g(a) &amp;\u2264 g(b) &#92;tag{3}<br \/>\n&#92;end{align}<br \/>\nEntonces,<br \/>\n&#92;begin{align}<br \/>\n   (f + g)(a) &amp;= f(a) + g(a)    &#92;&#92;<br \/>\n              &amp;\u2264 f(b) + g(b)    &amp;&amp;&#92;text{[por L1, (2) y (3)]} &#92;&#92;<br \/>\n              &amp;= (f + g)(b)<br \/>\n&#92;end{align}<\/p>\n<p><b>Demostraciones con Lean4<\/b><\/p>\n<pre lang=\"lean\">\nimport Mathlib.Data.Real.Basic\n\nvariable (f g : \u211d \u2192 \u211d)\n\n-- 1\u00aa demostraci\u00f3n\nexample\n  (mf : Monotone f)\n  (mg : Monotone g)\n  : Monotone (f + g) :=\nby\n  have h1 : \u2200 a b, a \u2264 b \u2192 (f + g) a \u2264 (f + g) b\n  { intros a b hab\n    have h2 : f a \u2264 f b := mf hab\n    have h3 : g a \u2264 g b := mg hab\n    calc (f + g) a\n         = f a + g a := rfl\n       _ \u2264 f b + g b := add_le_add h2 h3\n       _ = (f + g) b := rfl }\n  show Monotone (f + g)\n  exact h1\n\n-- 2\u00aa demostraci\u00f3n\nexample\n  (mf : Monotone f)\n  (mg : Monotone g)\n  : Monotone (f + g) :=\nby\n  have h1 : \u2200 a b, a \u2264 b \u2192 (f + g) a \u2264 (f + g) b\n  { intros a b hab\n    calc (f + g) a\n         = f a + g a := rfl\n       _ \u2264 f b + g b := add_le_add (mf hab) (mg hab)\n       _ = (f + g) b := rfl }\n  show Monotone (f + g)\n  exact h1\n\n-- 3\u00aa demostraci\u00f3n\nexample\n  (mf : Monotone f)\n  (mg : Monotone g)\n  : Monotone (f + g) :=\nby\n  have h1 : \u2200 a b, a \u2264 b \u2192 (f + g) a \u2264 (f + g) b\n  { intros a b hab\n    show (f + g) a \u2264 (f + g) b\n    exact add_le_add (mf hab) (mg hab) }\n  show Monotone (f + g)\n  exact h1\n\n-- 4\u00aa demostraci\u00f3n\nexample\n  (mf : Monotone f)\n  (mg : Monotone g)\n  : Monotone (f + g) :=\nby\n  -- a b : \u211d\n  -- hab : a \u2264 b\n  intros a b hab\n  apply add_le_add\n  . -- f a \u2264 f b\n    apply mf hab\n  . --  g a \u2264 g b\n    apply mg hab\n\n-- 5\u00aa demostraci\u00f3n\nexample\n  (mf : Monotone f)\n  (mg : Monotone g)\n  : Monotone (f + g) :=\n\u03bb _ _ hab \u21a6 add_le_add (mf hab) (mg hab)\n\n-- Lemas usados\n-- ============\n\n-- variable (a b c d : \u211d)\n-- #check (add_le_add : a \u2264 b \u2192 c \u2264 d \u2192 a + c \u2264 b + d)\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\/Suma_de_funciones_monotonas.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. 26.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Demostrar con Lean4 que la suma de dos funciones mon\u00f3tonas es mon\u00f3tona. Para ello, completar la siguiente teor\u00eda de Lean4: import Mathlib.Data.Real.Basic variable (f g : \u211d \u2192 \u211d) example (mf : Monotone f) (mg : Monotone g) : Monotone (f + g) := 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":[297,286,287],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/1648"}],"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=1648"}],"version-history":[{"count":8,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/1648\/revisions"}],"predecessor-version":[{"id":1705,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/1648\/revisions\/1705"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=1648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=1648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=1648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}