        {"id":566,"date":"2021-07-14T06:00:36","date_gmt":"2021-07-14T04:00:36","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=566"},"modified":"2021-07-06T18:37:21","modified_gmt":"2021-07-06T16:37:21","slug":"limite-de-la-suma-de-sucesiones-convergentes","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/limite-de-la-suma-de-sucesiones-convergentes\/","title":{"rendered":"L\u00edmite de la suma de sucesiones convergentes"},"content":{"rendered":"<p>En Lean, una sucesi\u00f3n u\u2080, u\u2081, u\u2082, &#8230; se puede representar mediante una funci\u00f3n (u : \u2115 \u2192 \u211d) de forma que u(n) es u\u2099.<\/p>\n<p>Se define que a es el l\u00edmite de la sucesi\u00f3n u, por<\/p>\n<pre lang=\"text\">\n   def limite : (\u2115 \u2192 \u211d) \u2192 \u211d \u2192 Prop :=\n   \u03bb u a, \u2200 \u03b5 > 0, \u2203 N, \u2200 n \u2265 N, |u n - a| < \u03b5\n<\/pre>\n<p>donde se usa la notaci\u00f3n |x| para el valor absoluto de x<\/p>\n<pre lang=\"text\">\n   notation `|`x`|` := abs x\n<\/pre>\n<p>Demostrar que el l\u00edmite de la suma de dos sucesiones convergentes es la suma de los l\u00edmites de dichas sucesiones.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/p>\n<pre lang=\"lean\">\nimport data.real.basic\n\nvariables (u v : \u2115 \u2192 \u211d)\nvariables (a b : \u211d)\n\nnotation `|`x`|` := abs x\n\ndef limite : (\u2115 \u2192 \u211d) \u2192 \u211d \u2192 Prop :=\n\u03bb u c, \u2200 \u03b5 > 0, \u2203 N, \u2200 n \u2265 N, |u n - c| < \u03b5\n\nexample\n  (hu : limite u a)\n  (hv : limite v b)\n  : limite (u + v) (a + b) :=\nsorry\n<\/pre>\n<p>[expand title=\"Soluciones con Lean\"]<\/p>\n<pre lang=\"lean\">\r\nimport data.real.basic\r\n\r\nvariables (u v : \u2115 \u2192 \u211d)\r\nvariables (a b : \u211d)\r\n\r\nnotation `|`x`|` := abs x\r\n\r\ndef limite : (\u2115 \u2192 \u211d) \u2192 \u211d \u2192 Prop :=\r\n\u03bb u c, \u2200 \u03b5 > 0, \u2203 N, \u2200 n \u2265 N, |u n - c| < \u03b5\r\n\r\n-- 1\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample\r\n  (hu : limite u a)\r\n  (hv : limite v b)\r\n  : limite (u + v) (a + b) :=\r\nbegin\r\n  intros \u03b5 h\u03b5,\r\n  have h\u03b52 : 0 < \u03b5 \/ 2,\r\n    { linarith },\r\n  cases hu (\u03b5 \/ 2) h\u03b52 with Nu hNu,\r\n  cases hv (\u03b5 \/ 2) h\u03b52 with Nv hNv,\r\n  clear hu hv h\u03b52 h\u03b5,\r\n  use max Nu Nv,\r\n  intros n hn,\r\n  have hn\u2081 : n \u2265 Nu,\r\n    { exact le_of_max_le_left hn },\r\n  specialize hNu n hn\u2081,\r\n  have hn\u2082 : n \u2265 Nv,\r\n    { exact le_of_max_le_right hn },\r\n  specialize hNv n hn\u2082,\r\n  clear hn hn\u2081 hn\u2082 Nu Nv,\r\n  calc |(u + v) n - (a + b)|\r\n       = |(u n + v n) - (a + b)|  : by refl\r\n   ... = |(u n - a) + (v n -  b)| : by {congr, ring}\r\n   ... \u2264 |u n - a| + |v n -  b|   : by apply abs_add\r\n   ... < \u03b5 \/ 2 + \u03b5 \/ 2            : by linarith\r\n   ... = \u03b5                        : by apply add_halves,\r\nend\r\n\r\n-- 2\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample\r\n  (hu : limite u a)\r\n  (hv : limite v b)\r\n  : limite (u + v) (a + b) :=\r\nbegin\r\n  intros \u03b5 h\u03b5,\r\n  cases hu (\u03b5\/2) (by linarith) with Nu hNu,\r\n  cases hv (\u03b5\/2) (by linarith) with Nv hNv,\r\n  use max Nu Nv,\r\n  intros n hn,\r\n  have hn\u2081 : n \u2265 Nu := le_of_max_le_left hn,\r\n  specialize hNu n hn\u2081,\r\n  have hn\u2082 : n \u2265 Nv := le_of_max_le_right hn,\r\n  specialize hNv n hn\u2082,\r\n  calc |(u + v) n - (a + b)|\r\n       = |(u n + v n) - (a + b)|  : by refl\r\n   ... = |(u n - a) + (v n -  b)| : by {congr, ring}\r\n   ... \u2264 |u n - a| + |v n -  b|   : by apply abs_add\r\n   ... < \u03b5 \/ 2 + \u03b5 \/ 2            : by linarith\r\n   ... = \u03b5                        : by apply add_halves,\r\nend\r\n\r\n-- 3\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nlemma max_ge_iff\r\n  {\u03b1 : Type*}\r\n  [linear_order \u03b1]\r\n  {p q r : \u03b1}\r\n  : r \u2265 max p q  \u2194 r \u2265 p \u2227 r \u2265 q :=\r\nmax_le_iff\r\n\r\nexample\r\n  (hu : limite u a)\r\n  (hv : limite v b)\r\n  : limite (u + v) (a + b) :=\r\nbegin\r\n  intros \u03b5 h\u03b5,\r\n  cases hu (\u03b5\/2) (by linarith) with Nu hNu,\r\n  cases hv (\u03b5\/2) (by linarith) with Nv hNv,\r\n  use max Nu Nv,\r\n  intros n hn,\r\n  cases max_ge_iff.mp hn with hn\u2081 hn\u2082,\r\n  have cota\u2081 : |u n - a| < \u03b5\/2 := hNu n hn\u2081,\r\n  have cota\u2082 : |v n - b| < \u03b5\/2 := hNv n hn\u2082,\r\n  calc |(u + v) n - (a + b)|\r\n       = |u n + v n - (a + b)|   : by rfl\r\n   ... = |(u n - a) + (v n - b)| : by { congr, ring }\r\n   ... \u2264 |u n - a| + |v n - b|   : by apply abs_add\r\n   ... < \u03b5                       : by linarith,\r\nend\r\n\r\n-- 4\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample\r\n  (hu : limite u a)\r\n  (hv : limite v b)\r\n  : limite (u + v) (a + b) :=\r\nbegin\r\n  intros \u03b5 h\u03b5,\r\n  cases hu (\u03b5\/2) (by linarith) with Nu hNu,\r\n  cases hv (\u03b5\/2) (by linarith) with Nv hNv,\r\n  use max Nu Nv,\r\n  intros n hn,\r\n  cases max_ge_iff.mp hn with hn\u2081 hn\u2082,\r\n  calc |(u + v) n - (a + b)|\r\n       = |u n + v n - (a + b)|   : by refl\r\n   ... = |(u n - a) + (v n - b)| : by { congr, ring }\r\n   ... \u2264 |u n - a| + |v n - b|   : by apply abs_add\r\n   ... < \u03b5\/2 + \u03b5\/2               : add_lt_add (hNu n hn\u2081) (hNv n hn\u2082)\r\n   ... = \u03b5                       : by simp\r\nend\r\n\r\n-- 5\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample\r\n  (hu : limite u a)\r\n  (hv : limite v b)\r\n  : limite (u + v) (a + b) :=\r\nbegin\r\n  intros \u03b5 h\u03b5,\r\n  cases hu (\u03b5\/2) (by linarith) with Nu hNu,\r\n  cases hv (\u03b5\/2) (by linarith) with Nv hNv,\r\n  use max Nu Nv,\r\n  intros n hn,\r\n  rw max_ge_iff at hn,\r\n  calc |(u + v) n - (a + b)|\r\n       = |u n + v n - (a + b)|   : by refl\r\n   ... = |(u n - a) + (v n - b)| : by { congr, ring }\r\n   ... \u2264 |u n - a| + |v n - b|   : by apply abs_add\r\n   ... < \u03b5                       : by linarith [hNu n (by linarith), hNv n (by linarith)],\r\nend\r\n\r\n-- 6\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample\r\n  (hu : limite u a)\r\n  (hv : limite v b)\r\n  : limite (u + v) (a + b) :=\r\nbegin\r\n  intros \u03b5 H\u03b5,\r\n  cases hu (\u03b5\/2) (by linarith) with L HL,\r\n  cases hv (\u03b5\/2) (by linarith) with M HM,\r\n  set N := max L M with hN,\r\n  use N,\r\n  have HLN : N \u2265 L := le_max_left _ _,\r\n  have HMN : N \u2265 M := le_max_right _ _,\r\n  intros n Hn,\r\n  have H3 : |u n - a| < \u03b5\/2 := HL n (by linarith),\r\n  have H4 : |v n - b| < \u03b5\/2 := HM n (by linarith),\r\n  calc |(u + v) n - (a + b)|\r\n       = |(u n + v n) - (a + b)|   : by refl\r\n   ... = |(u n - a) + (v n - b)|   : by { congr, ring }\r\n   ... \u2264 |(u n - a)| + |(v n - b)| : by apply abs_add\r\n   ... < \u03b5\/2 + \u03b5\/2                 : by linarith\r\n   ... = \u03b5                         : by ring\r\nend\r\n<\/pre>\n<p>Se puede interactuar con la prueba anterior en <a href=\"https:\/\/www.cs.us.es\/~jalonso\/lean-web-editor\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus\/main\/src\/Limite_de_la_suma_de_sucesiones_convergentes.lean\" rel=\"noopener noreferrer\" target=\"_blank\">esta sesi\u00f3n con Lean<\/a>.<\/p>\n<p>En los comentarios se pueden escribir otras soluciones, escribiendo el c\u00f3digo entre una l\u00ednea con &#60;pre lang=&quot;lean&quot;&#62; y otra con &#60;\/pre&#62;<br \/>\n[\/expand]<\/p>\n<p>[expand title=\"Soluciones con Isabelle\/HOL\"]<\/p>\n<pre lang=\"isar\">\r\ntheory Limite_de_la_suma_de_sucesiones_convergentes\r\nimports Main HOL.Real\r\nbegin\r\n\r\ndefinition limite :: \"(nat \u21d2 real) \u21d2 real \u21d2 bool\"\r\n  where \"limite u c \u27f7 (\u2200\u03b5>0. \u2203k::nat. \u2200n\u2265k. \u00a6u n - c\u00a6 < \u03b5)\"\r\n\r\n(* 1\u00aa demostraci\u00f3n *)\r\n\r\nlemma\r\n  assumes \"limite u a\"\r\n          \"limite v b\"\r\n  shows   \"limite (\u03bb n. u n + v n) (a + b)\"\r\nproof (unfold limite_def)\r\n  show \"\u2200\u03b5>0. \u2203k. \u2200n\u2265k. \u00a6(u n + v n) - (a + b)\u00a6 < \u03b5\"\r\n  proof (intro allI impI)\r\n    fix \u03b5 :: real\r\n    assume \"0 < \u03b5\"\r\n    then have \"0 < \u03b5\/2\"\r\n      by simp\r\n    then have \"\u2203k. \u2200n\u2265k. \u00a6u n - a\u00a6 < \u03b5\/2\"\r\n      using assms(1) limite_def by blast\r\n    then obtain Nu where hNu : \"\u2200n\u2265Nu. \u00a6u n - a\u00a6 < \u03b5\/2\"\r\n      by (rule exE)\r\n    then have \"\u2203k. \u2200n\u2265k. \u00a6v n - b\u00a6 < \u03b5\/2\"\r\n      using \u20390 < \u03b5\/2\u203a assms(2) limite_def by blast\r\n    then obtain Nv where hNv : \"\u2200n\u2265Nv. \u00a6v n - b\u00a6 < \u03b5\/2\"\r\n      by (rule exE)\r\n    have \"\u2200n\u2265max Nu Nv. \u00a6(u n + v n) - (a + b)\u00a6 < \u03b5\"\r\n    proof (intro allI impI)\r\n      fix n :: nat\r\n      assume \"n \u2265 max Nu Nv\"\r\n      have \"\u00a6(u n + v n) - (a + b)\u00a6 = \u00a6(u n - a) + (v n - b)\u00a6\"\r\n        by simp\r\n      also have \"\u2026 \u2264 \u00a6u n - a\u00a6 + \u00a6v n - b\u00a6\"\r\n        by simp\r\n      also have \"\u2026 < \u03b5\/2 + \u03b5\/2\"\r\n        using hNu hNv \u2039max Nu Nv \u2264 n\u203a by fastforce\r\n      finally show \"\u00a6(u n + v n) - (a + b)\u00a6 < \u03b5\"\r\n        by simp\r\n    qed\r\n    then show \"\u2203k. \u2200n\u2265k. \u00a6u n + v n - (a + b)\u00a6 < \u03b5 \"\r\n      by (rule exI)\r\n  qed\r\nqed\r\n\r\n(* 2\u00aa demostraci\u00f3n *)\r\n\r\nlemma\r\n  assumes \"limite u a\"\r\n          \"limite v b\"\r\n  shows   \"limite (\u03bb n. u n + v n) (a + b)\"\r\nproof (unfold limite_def)\r\n  show \"\u2200\u03b5>0. \u2203k. \u2200n\u2265k. \u00a6(u n + v n) - (a + b)\u00a6 < \u03b5\"\r\n  proof (intro allI impI)\r\n    fix \u03b5 :: real\r\n    assume \"0 < \u03b5\"\r\n    then have \"0 < \u03b5\/2\" by simp\r\n    obtain Nu where hNu : \"\u2200n\u2265Nu. \u00a6u n - a\u00a6 < \u03b5\/2\"\r\n      using \u20390 < \u03b5\/2\u203a assms(1) limite_def by blast\r\n    obtain Nv where hNv : \"\u2200n\u2265Nv. \u00a6v n - b\u00a6 < \u03b5\/2\"\r\n      using \u20390 < \u03b5\/2\u203a assms(2) limite_def by blast\r\n    have \"\u2200n\u2265max Nu Nv. \u00a6(u n + v n) - (a + b)\u00a6 < \u03b5\"\r\n      using hNu hNv\r\n      by (smt (verit, ccfv_threshold) field_sum_of_halves max.boundedE)\r\n    then show \"\u2203k. \u2200n\u2265k. \u00a6u n + v n - (a + b)\u00a6 < \u03b5 \"\r\n      by blast\r\n  qed\r\nqed\r\n\r\nend\r\n<\/pre>\n<p>En los comentarios se pueden escribir otras soluciones, escribiendo el c\u00f3digo entre una l\u00ednea con &#60;pre lang=&quot;isar&quot;&#62; y otra con &#60;\/pre&#62;<br \/>\n[\/expand]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>En Lean, una sucesi\u00f3n u\u2080, u\u2081, u\u2082, &#8230; se puede representar mediante una funci\u00f3n (u : \u2115 \u2192 \u211d) de forma que u(n) es u\u2099. Se define que a es el l\u00edmite de la sucesi\u00f3n u, por def limite : (\u2115 \u2192 \u211d) \u2192 \u211d \u2192 Prop := \u03bb u a, \u2200 \u03b5 > 0, \u2203 N, \u2200 n \u2265 N, |u n &#8211; a| < \u03b5 donde se usa la notaci\u00f3n |x| para el valor absoluto de x notation `|`x`|` := abs x Demostrar que el l\u00edmite de la suma de dos sucesiones convergentes es la suma de los l\u00edmites de dichas sucesiones. Para ello, completar la siguiente teor\u00eda de Lean: import data.real.basic variables (u v : \u2115 \u2192 \u211d) variables (a b :...\n<\/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":[14],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/566"}],"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=566"}],"version-history":[{"count":1,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/566\/revisions"}],"predecessor-version":[{"id":567,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/566\/revisions\/567"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}