{"id":7846,"date":"2022-11-20T08:46:35","date_gmt":"2022-11-20T07:46:35","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/?p=7846"},"modified":"2022-11-20T08:46:35","modified_gmt":"2022-11-20T07:46:35","slug":"20-nov-22","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/20-nov-22\/","title":{"rendered":"DAO: La semana en Calculemus (18 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. El producto de dos funciones impares es par<\/a><\/li>\n<li><a href=\"#ej2\">2. El producto de una funci\u00f3n par por una impar es impar<\/a><\/li>\n<li><a href=\"#ej3\">3. Si f es par y g es impar, entonces f \u2218 g es par<\/a><\/li>\n<li><a href=\"#ej4\">4. Para cualquier conjunto s, s \u2286 s<\/a><\/li>\n<li><a href=\"#ej5\">5. Si r \u2286 s y s \u2286 t, entonces r \u2286 t<\/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. El producto de dos funciones impares es par<\/h3>\n<p>La funci\u00f3n f de \u211d en \u211d es par si, para todo x, f(-x) = f(x) y es impar si, para todo x, f(-x) -f(x).<\/p>\n<p>Demostrar que el producto de dos funciones impares es par.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/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)\ndef impar  (f : \u211d \u2192 \u211d) : Prop := \u2200 x, f x = -f (-x)\n\nexample\n  (hf : impar f)\n  (hg : impar 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)\ndef impar  (f : \u211d \u2192 \u211d) : Prop := \u2200 x, f x = -f (-x)\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hf : impar f)\n  (hg : impar 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 (-x) * g (-x)       : neg_mul_neg (f (-x)) (g (-x))\n   ... = (f * g) (-x)          : rfl,\nend\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hf : impar f)\n  (hg : impar 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 (-x) * g (-x)   : by rw neg_mul_neg\n   ... = (f * g) (-x)      : rfl\nend\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hf : impar f)\n  (hg : impar 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, neg_mul_neg]\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\/Producto_funciones_impares.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. 29.<\/li>\n<\/ul>\n<p><a name=\"ej2\"><\/a><\/p>\n<h3>2. El producto de una funci\u00f3n par por una impar es impar<\/h3>\n<p>La funci\u00f3n f de \u211d en \u211d es par si, para todo x, f(-x) = f(x) y es impar si, para todo x, f(-x) -f(x).<\/p>\n<p>Demostrar que el producto de una funci\u00f3n par por una impar es impar.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/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)\ndef impar  (f : \u211d \u2192 \u211d) : Prop := \u2200 x, f x = -f (-x)\n\nexample\n  (hf : par f)\n  (hg : impar g)\n  : impar (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)\ndef impar  (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 : impar g)\n  : impar (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 (-x) * g (-x))   : mul_neg (f (-x)) (g (-x))\n   ... = -(f * g) (-x)        : rfl,\nend\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hf : par f)\n  (hg : impar g)\n  : impar (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 (-x) * g (-x)) : by rw mul_neg\n   ... = -(f * g) (-x)      : rfl\nend\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hf : par f)\n  (hg : impar g)\n  : impar (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, neg_mul_eq_mul_neg]\n   ... = -((\u03bb x, f x * g x) (-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\/Producto_de_funcion_par_por_impar.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. 29.<\/li>\n<\/ul>\n<p><a name=\"ej3\"><\/a><\/p>\n<h3>3. Si f es par y g es impar, entonces f \u2218 g es par<\/h3>\n<p>La funci\u00f3n f de \u211d en \u211d es par si, para todo x, f(-x) = f(x) y es impar si, para todo x, f(-x) -f(x).<\/p>\n<p>Demostrar que si f es par y g es impar, entonces f \u2218 g es par.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/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)\ndef impar  (f : \u211d \u2192 \u211d) : Prop := \u2200 x, f x = -f (-x)\n\nexample\n  (hf : par f)\n  (hg : impar g)\n  : par (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\nvariables (f g : \u211d \u2192 \u211d)\n\ndef par (f : \u211d \u2192 \u211d) : Prop    := \u2200 x, f x = f (-x)\ndef impar  (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 : impar g)\n  : par (f \u2218 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 \u2218 g) x\n       = f (g x)      : rfl\n   ... = f (-g (-x))  : congr_arg f (hg x)\n   ... = f (g (-x))   : eq.symm (hf (g (-x)))\n   ... = (f \u2218 g) (-x) : rfl\nend\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (hf : par f)\n  (hg : impar g)\n  : par (f \u2218 g) :=\nbegin\n  intro x,\n  calc (f \u2218 g) x\n       = f (g x)      : rfl\n   ... = f (-g (-x))  : by rw hg\n   ... = f (g (-x))   : by rw \u2190hf\n   ... = (f \u2218 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\/Composicion_par_impar.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. 29.<\/li>\n<\/ul>\n<p><a name=\"ej4\"><\/a><\/p>\n<h3>4. Para cualquier conjunto s, s \u2286 s<\/h3>\n<p>Demostrar que, para cualquier conjunto s, s \u2286 s<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/p>\n<pre lang=\"lean\">\nimport tactic\nvariables {\u03b1 : Type*} (s : set \u03b1)\n\nexample : s \u2286 s :=\nsorry\n<\/pre>\n<p><!--more--><\/p>\n<p><b>Soluciones con Lean<\/b><\/p>\n<pre lang=\"lean\">\nimport tactic\nvariables {\u03b1 : Type*} (s : set \u03b1)\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample : s \u2286 s :=\nbegin\n  assume x,\n  assume xs: x \u2208 s,\n  show x \u2208 s,\n    by exact xs,\nend\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample : s \u2286 s :=\nbegin\n  intros x xs,\n  exact xs,\nend\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample : s \u2286 s :=\n\u03bb x (xs : x \u2208 s), xs\n\n-- 4\u00aa demostraci\u00f3n\n-- ===============\n\nexample : s \u2286 s :=\n-- by library_search\nrfl.subset\n\n-- 5\u00aa demostraci\u00f3n\n-- ===============\n\nexample : s \u2286 s :=\n-- by hint\nby refl\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\/Propiedad_reflexiva_del_subconjunto.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. 29.<\/li>\n<\/ul>\n<p><a name=\"ej5\"><\/a><\/p>\n<h3>5. Si r \u2286 s y s \u2286 t, entonces r \u2286 t<\/h3>\n<p>Demostrar que si r \u2286 s y s \u2286 t, entonces r \u2286 t.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/p>\n<pre lang=\"lean\">\nimport tactic\n\nvariables {\u03b1 : Type*}\nvariables r s t : set \u03b1\n\nexample\n  (rs : r \u2286 s)\n  (st : s \u2286 t)\n  : r \u2286 t :=\nsorry\n<\/pre>\n<p><!--more--><\/p>\n<p><b>Soluciones con Lean<\/b><\/p>\n<pre lang=\"lean\">\nimport tactic\n\nvariables {\u03b1 : Type*}\nvariables r s t : set \u03b1\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (rs : r \u2286 s)\n  (st : s \u2286 t)\n  : r \u2286 t :=\nbegin\n  assume x,\n  assume xr : x \u2208 r,\n  have h1 : x \u2208 s := rs xr,\n  show x \u2208 t,\n    by exact st h1,\nend\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (rs : r \u2286 s)\n  (st : s \u2286 t)\n  : r \u2286 t :=\nbegin\n  intros x xr,\n  apply st,\n  apply rs,\n  exact xr\nend\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (rs : r \u2286 s)\n  (st : s \u2286 t)\n  : r \u2286 t :=\n\u03bb x xr, st (rs xr)\n\n-- 4\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (rs : r \u2286 s)\n  (st : s \u2286 t)\n  : r \u2286 t :=\n-- by library_search\nset.subset.trans rs st\n\n-- 5\u00aa demostraci\u00f3n\n-- ===============\n\nexample\n  (rs : r \u2286 s)\n  (st : s \u2286 t)\n  : r \u2286 t :=\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\/Propiedad_transitiva_del_subconjunto.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. 29.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Esta semana he publicado en Calculemus las demostraciones con Lean de las siguientes propiedades: 1. El producto de dos funciones impares es par 2. El producto de una funci\u00f3n par por una impar es impar 3. Si f es par y g es impar, entonces f \u2218 g es par 4. Para cualquier conjunto s,&#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\/7846"}],"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=7846"}],"version-history":[{"count":1,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/posts\/7846\/revisions"}],"predecessor-version":[{"id":7847,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/posts\/7846\/revisions\/7847"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/media?parent=7846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/categories?post=7846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/tags?post=7846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}