{"id":7842,"date":"2022-11-13T11:27:41","date_gmt":"2022-11-13T10:27:41","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/?p=7842"},"modified":"2022-11-13T11:27:41","modified_gmt":"2022-11-13T10:27:41","slug":"13-nov-22","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/13-nov-22\/","title":{"rendered":"DAO: La semana en Calculemus (11 de noviembre de 2022)"},"content":{"rendered":"<p>Esta semana he publicado en <a href=\"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/\">Calculemus<\/a> las demostraciones con Lean de las siguientes propiedades:<\/p>\n<ul>\n<li><a href=\"#ej1\">1. Si a es una cota superior no negativa de f y b es es una cota superior de la funci\u00f3n no negativa g, entonces a\u00b7b es una cota superior de f\u00b7g<\/a><\/li>\n<li><a href=\"#ej2\">2. La suma de dos funciones mon\u00f3tonas es mon\u00f3tona<\/a><\/li>\n<li><a href=\"#ej3\">3. Si f es mon\u00f3tona y c \u2265 0, entonces c\u00b7f es mon\u00f3tona<\/a><\/li>\n<li><a href=\"#ej4\">4. La composici\u00f3n de dos funciones mon\u00f3tonas es mon\u00f3tona<\/a><\/li>\n<li><a href=\"#ej5\">5. La suma de dos funciones pares es par<\/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 a es una cota superior no negativa de f y b es es una cota superior de la funci\u00f3n no negativa g, entonces a\u00b7b es una cota superior de f\u00b7g<\/h3>\n<p>Demostrar que si a es una cota superior no negativa de f y b es es una cota superior de la funci\u00f3n no negativa g, entonces a\u00b7b es una cota superior de f\u00b7g.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/p>\n<pre lang=\"lean\">\nimport data.real.basic\n\ndef cota_superior (f : \u211d \u2192 \u211d) (a : \u211d) : Prop :=\n\u2200 x, f x \u2264 a\n\ndef no_negativa (f : \u211d \u2192 \u211d) : Prop :=\n\u2200 x, 0 \u2264 f x\n\nvariables (f g : \u211d \u2192 \u211d)\nvariables (a b : \u211d)\n\nexample\n  (hfa : cota_superior f a)\n  (hgb : cota_superior g b)\n  (nng : no_negativa g)\n  (nna : 0 \u2264 a)\n  : cota_superior (f * g) (a * b) :=\nsorry\n<\/pre>\n<p><!--more--><\/p>\n<p><b>Soluciones con Lean<\/b><\/p>\n<pre lang=\"lean\">\nimport data.real.basic\n\ndef cota_superior (f : \u211d \u2192 \u211d) (a : \u211d) : Prop :=\n\u2200 x, f x \u2264 a\n\ndef no_negativa (f : \u211d \u2192 \u211d) : Prop :=\n\u2200 x, 0 \u2264 f x\n\nvariables (f g : \u211d \u2192 \u211d)\nvariables (a b : \u211d)\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hfa : cota_superior f a)\n  (hgb : cota_superior g b)\n  (nng : no_negativa g)\n  (nna : 0 \u2264 a)\n  : cota_superior (f * g) (a * b) :=\nbegin\n  have h1 : \u2200 x, f x * g x \u2264 a * b,\n    { intro x,\n      have h2 : f x \u2264 a := hfa x,\n      have h3 : g x \u2264 b := hgb x,\n      have h4 : 0 \u2264 g x := nng x,\n      show f x * g x \u2264 a * b,\n        by exact mul_le_mul h2 h3 h4 nna, },\n  show cota_superior (f * g) (a * b),\n    by exact h1,\nend\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hfa : cota_superior f a)\n  (hgb : cota_superior g b)\n  (nng : no_negativa g)\n  (nna : 0 \u2264 a)\n  : cota_superior (f * g) (a * b) :=\nbegin\n  intro x,\n  change f x * g x \u2264 a * b,\n  apply mul_le_mul,\n  apply hfa,\n  apply hgb,\n  apply nng,\n  apply nna\nend\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hfa : cota_superior f a)\n  (hgb : cota_superior g b)\n  (nng : no_negativa g)\n  (nna : 0 \u2264 a)\n  : cota_superior (f * g) (a * b) :=\nbegin\n  dunfold cota_superior no_negativa at *,\n  intro x,\n  have h1:= hfa x,\n  have h2:= hgb x,\n  have h3:= nng x,\n  exact mul_le_mul h1 h2 h3 nna,\nend\n\n-- 4\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hfa : cota_superior f a)\n  (hgb : cota_superior g b)\n  (nng : no_negativa g)\n  (nna : 0 \u2264 a)\n  : cota_superior (f * g) (a * b) :=\nbegin\n  dunfold cota_superior no_negativa at *,\n  intro x,\n  specialize hfa x,\n  specialize hgb x,\n  specialize nng x,\n  exact mul_le_mul hfa hgb nng nna,\nend\n\n-- 5\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hfa : cota_superior f a)\n  (hgb : cota_superior g b)\n  (nng : no_negativa g)\n  (nna : 0 \u2264 a)\n  : cota_superior (f * g) (a * b) :=\n\u03bb x, mul_le_mul (hfa x) (hgb x) (nng x) nna\n<\/pre>\n<p>Se puede interactuar con la prueba anterior en <a href=\"https:\/\/leanprover-community.github.io\/lean-web-editor\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus\/main\/src\/Cota_sup_del_producto_de_funciones.lean\" rel=\"noopener noreferrer\" target=\"_blank\">esta sesi\u00f3n con Lean<\/a>.<\/p>\n<p><b>Referencias<\/b><\/p>\n<ul>\n<li>J. Avigad, K. Buzzard, R.Y. Lewis y P. Massot. <a href=\"https:\/\/bit.ly\/3U4UjBk\">Mathematics in Lean<\/a>, p. 27.<\/li>\n<\/ul>\n<p><a name=\"ej2\"><\/a><\/p>\n<h3>2. La suma de dos funciones mon\u00f3tonas es mon\u00f3tona<\/h3>\n<p>Demostrar que la suma de dos funciones mon\u00f3tonas es mon\u00f3tona.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/p>\n<pre lang=\"lean\">\nimport data.real.basic\n\nvariables (f g : \u211d \u2192 \u211d)\n\nexample\n  (mf : monotone f)\n  (mg : monotone g)\n  : monotone (f + g) :=\nsorry\n<\/pre>\n<p><!--more--><\/p>\n<p><b>Soluciones con Lean<\/b><\/p>\n<pre lang=\"lean\">\nimport data.real.basic\n\nvariables (f g : \u211d \u2192 \u211d)\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (mf : monotone f)\n  (mg : monotone g)\n  : monotone (f + g) :=\nbegin\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    by exact h1,\nend\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (mf : monotone f)\n  (mg : monotone g)\n  : monotone (f + g) :=\nbegin\n  intros a b hab,\n  apply add_le_add,\n  apply mf hab,\n  apply mg hab\nend\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (mf : monotone f)\n  (mg : monotone g)\n  : monotone (f + g) :=\n\u03bb a b hab, add_le_add (mf hab) (mg hab)\n<\/pre>\n<p>Se puede interactuar con la prueba anterior en <a href=\"https:\/\/leanprover-community.github.io\/lean-web-editor\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus\/main\/src\/Suma_de_funciones_monotonas.lean\" rel=\"noopener noreferrer\" target=\"_blank\">esta sesi\u00f3n con Lean<\/a>.<\/p>\n<p><b>Referencias<\/b><\/p>\n<ul>\n<li>J. Avigad, K. Buzzard, R.Y. Lewis y P. Massot. <a href=\"https:\/\/bit.ly\/3U4UjBk\">Mathematics in Lean<\/a>, p. 28.<\/li>\n<\/ul>\n<p><a name=\"ej3\"><\/a><\/p>\n<h3>3. Si f es mon\u00f3tona y c \u2265 0, entonces c\u00b7f es mon\u00f3tona<\/h3>\n<p>Demostrar que si f es mon\u00f3tona y c \u2265 0, entonces c\u00b7f es mon\u00f3tona.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/p>\n<pre lang=\"lean\">\nimport data.real.basic\n\nvariables (f : \u211d \u2192 \u211d)\nvariable  {c : \u211d}\n\nexample\n  (mf : monotone f)\n  (nnc : 0 \u2264 c)\n  : monotone (\u03bb x, c * f x) :=\nsorry\n<\/pre>\n<p><!--more--><\/p>\n<p><b>Soluciones con Lean<\/b><\/p>\n<pre lang=\"lean\">\nimport data.real.basic\n\nvariables (f : \u211d \u2192 \u211d)\nvariable  {c : \u211d}\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (mf : monotone f)\n  (nnc : 0 \u2264 c)\n  : monotone (\u03bb x, c * f x) :=\nbegin\n  have h1 : \u2200 a b, a \u2264 b \u2192 (\u03bb x, c * f x) a \u2264 (\u03bb x, c * f x) b,\n    { intros a b hab,\n      have h2 : f a \u2264 f b := mf hab,\n      have h3 : c * f a \u2264 c * f b := mul_le_mul_of_nonneg_left h2 nnc,\n      show (\u03bb x, c * f x) a \u2264 (\u03bb x, c * f x) b,\n        by exact h3, },\n  show monotone (\u03bb x, c * f x),\n    by exact h1,\nend\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (mf : monotone f)\n  (nnc : 0 \u2264 c)\n  : monotone (\u03bb x, c * f x) :=\nbegin\n  intros a b hab,\n  apply mul_le_mul_of_nonneg_left,\n  apply mf hab,\n  apply nnc\nend\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample (mf : monotone f) (nnc : 0 \u2264 c) :\n  monotone (\u03bb x, c * f x) :=\n\u03bb a b hab, mul_le_mul_of_nonneg_left (mf hab) nnc\n<\/pre>\n<p>Se puede interactuar con la prueba anterior en <a href=\"https:\/\/leanprover-community.github.io\/lean-web-editor\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus\/main\/src\/Producto_de_un_positivo_por_una_funcion_monotona.lean\" rel=\"noopener noreferrer\" target=\"_blank\">esta sesi\u00f3n con Lean<\/a>.<\/p>\n<p><b>Referencias<\/b><\/p>\n<ul>\n<li>J. Avigad, K. Buzzard, R.Y. Lewis y P. Massot. <a href=\"https:\/\/bit.ly\/3U4UjBk\">Mathematics in Lean<\/a>, p. 28.<\/li>\n<\/ul>\n<p><a name=\"ej4\"><\/a><\/p>\n<h3>4. La composici\u00f3n de dos funciones mon\u00f3tonas es mon\u00f3tona<\/h3>\n<p>Demostrar que la composici\u00f3n de dos funciones mon\u00f3tonas es mon\u00f3tona.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/p>\n<pre lang=\"lean\">\nimport data.real.basic\n\nvariables (f g : \u211d \u2192 \u211d)\n\nexample\n  (mf : monotone f)\n  (mg : monotone g)\n  : monotone (f \u2218 g) :=\nsorry\n<\/pre>\n<p><!--more--><\/p>\n<p><b>Soluciones con Lean<\/b><\/p>\n<pre lang=\"lean\">\nimport data.real.basic\n\nvariables (f g : \u211d \u2192 \u211d)\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (mf : monotone f)\n  (mg : monotone g)\n  : monotone (f \u2218 g) :=\nbegin\n  have h1 : \u2200 a b, a \u2264 b \u2192 (f \u2218 g) a \u2264 (f \u2218 g) b,\n    { intros a b hab,\n      have h1 : g a \u2264 g b := mg hab,\n      have h2 : f (g a) \u2264 f (g b) := mf h1,\n      show (f \u2218 g) a \u2264 (f \u2218 g) b,\n        by exact h2, },\n  show monotone (f \u2218 g),\n    by exact h1,\nend\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (mf : monotone f)\n  (mg : monotone g)\n  : monotone (f \u2218 g) :=\nbegin\n  intros a b hab,\n  apply mf,\n  apply mg,\n  apply hab\nend\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (mf : monotone f)\n  (mg : monotone g)\n  : monotone (f \u2218 g) :=\n\u03bb a b hab, mf (mg hab)\n\n-- 4\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (mf : monotone f)\n  (mg : monotone g)\n  : monotone (f \u2218 g) :=\n-- by library_search\nmonotone.comp mf mg\n\n-- 5\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (mf : monotone f)\n  (mg : monotone g)\n  : monotone (f \u2218 g) :=\n-- by hint\nby tauto\n<\/pre>\n<p>Se puede interactuar con la prueba anterior en <a href=\"https:\/\/leanprover-community.github.io\/lean-web-editor\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus\/main\/src\/Composicion_de_funciones_monotonas.lean\" rel=\"noopener noreferrer\" target=\"_blank\">esta sesi\u00f3n con Lean<\/a>.<\/p>\n<p><b>Referencias<\/b><\/p>\n<ul>\n<li>J. Avigad, K. Buzzard, R.Y. Lewis y P. Massot. <a href=\"https:\/\/bit.ly\/3U4UjBk\">Mathematics in Lean<\/a>, p. 28.<\/li>\n<\/ul>\n<p><a name=\"ej5\"><\/a><\/p>\n<h3>5. La suma de dos funciones pares es par<\/h3>\n<p>La funci\u00f3n f de \u211d en \u211d es par si, para todo x, f(-x) = f(x).<\/p>\n<p>Demostrar que la suma de dos funciones pares es par.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/p>\n<pre lang=\"lean\">\nimport data.real.basic\n\nvariables (f g : \u211d \u2192 \u211d)\n\ndef par (f : \u211d \u2192 \u211d) : Prop := \u2200 x, f x = f (-x)\n\nexample\n  (hf : par f)\n  (hg : par g)\n  : par (f + g) :=\nsorry\n<\/pre>\n<p><!--more--><\/p>\n<p><b>Soluciones con Lean<\/b><\/p>\n<pre lang=\"lean\">\nimport data.real.basic\nvariables (f g : \u211d \u2192 \u211d)\n\ndef par (f : \u211d \u2192 \u211d) : Prop := \u2200 x, f x = f (-x)\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hf : par f)\n  (hg : par g)\n  : par (f + g) :=\nbegin\n  intro x,\n  have h1 : f x = f (-x) := hf x,\n  have h2 : g x = g (-x) := hg x,\n  calc (f + g) x\n       = f x + g x       : rfl\n   ... = f (-x) + g x    : congr_arg (+ g x) h1\n   ... = f (-x) + g (-x) : congr_arg ((+) (f (-x))) h2\n   ... = (f + g) (-x)    : rfl\nend\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hf : par f)\n  (hg : par g)\n  : par (f + g) :=\nbegin\n  intro x,\n  calc (f + g) x\n       = f x + g x       : rfl\n   ... = f (-x) + g (-x) : by rw [hf, hg]\n   ... = (f + g) (-x)    : rfl\nend\n<\/pre>\n<p>Se puede interactuar con la prueba anterior en <a href=\"https:\/\/leanprover-community.github.io\/lean-web-editor\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus\/main\/src\/Suma_funciones_pares.lean\" rel=\"noopener noreferrer\" target=\"_blank\">esta sesi\u00f3n con Lean<\/a>.<\/p>\n<p><b>Referencias<\/b><\/p>\n<ul>\n<li>J. Avigad, K. Buzzard, R.Y. Lewis y P. Massot. <a href=\"https:\/\/bit.ly\/3U4UjBk\">Mathematics in Lean<\/a>, p. 28.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Esta semana he publicado en Calculemus las demostraciones con Lean de las siguientes propiedades: 1. Si a es una cota superior no negativa de f y b es es una cota superior de la funci\u00f3n no negativa g, entonces a\u00b7b es una cota superior de f\u00b7g 2. La suma de dos funciones mon\u00f3tonas es mon\u00f3tona&#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\/7842"}],"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=7842"}],"version-history":[{"count":1,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/posts\/7842\/revisions"}],"predecessor-version":[{"id":7843,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/posts\/7842\/revisions\/7843"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/media?parent=7842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/categories?post=7842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/tags?post=7842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}