{"id":7738,"date":"2022-05-08T17:52:05","date_gmt":"2022-05-08T15:52:05","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/?p=7738"},"modified":"2022-05-08T17:52:05","modified_gmt":"2022-05-08T15:52:05","slug":"dao-la-semana-en-calculemus-del-2-al-6-de-mayo-de-2022","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/dao-la-semana-en-calculemus-del-2-al-6-de-mayo-de-2022\/","title":{"rendered":"DAO: La semana en Calculemus (del 2 al 6 de mayo de 2022)"},"content":{"rendered":"<p>Esta semana he publicado en <a href=\"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/\">Calculemus<\/a> las soluciones de los siguientes problemas:<\/p>\n<ul>\n<li><a href=\"#ej1\">1. Imagen de la uni\u00f3n<\/a><\/li>\n<li><a href=\"#ej2\">2. Teorema de Cantor<\/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. Imagen de la uni\u00f3n<\/h3>\n<p>En Lean, la imagen de un conjunto s por una funci\u00f3n f se representa por <code>f '' s<\/code>; es decir, <code>f '' s = {y | \u2203 x, x \u2208 s \u2227 f x = y}<\/code><\/p>\n<p>Demostrar que <code>f '' (s \u222a t) = f '' s \u222a f '' t<\/code><\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/p>\n<pre lang=\"lean\">\nimport data.set.basic\nimport tactic\n\nopen set\n\nvariables {\u03b1 : Type*} {\u03b2 : Type*}\nvariable  f : \u03b1 \u2192 \u03b2\nvariables s t : set \u03b1\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nsorry\n<\/pre>\n<p><!--more--><\/p>\n<p><strong>Soluciones con Lean<\/strong><\/p>\n<pre lang=\"lean\">\nimport data.set.basic\nimport tactic\n\nopen set\n\nvariables {\u03b1 : Type*} {\u03b2 : Type*}\nvariable  f : \u03b1 \u2192 \u03b2\nvariables s t : set \u03b1\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nbegin\n  ext y,\n  split,\n  { intro h,\n    rw mem_image at h,\n    cases h with x hx,\n    cases hx with xst fxy,\n    rw \u2190 fxy,\n    rw mem_union at xst,\n    cases xst with xs xt,\n    { apply mem_union_left,\n      apply mem_image_of_mem,\n      exact xs, },\n    { apply mem_union_right,\n      apply mem_image_of_mem,\n      exact xt, }},\n  { intro h,\n    rw mem_union at h,\n    cases h with yfs yft,\n    { rw mem_image,\n      rw mem_image at yfs,\n      cases yfs with x hx,\n      cases hx with xs fxy,\n      use x,\n      split,\n      { apply mem_union_left,\n        exact xs, },\n      { exact fxy, }},\n    { rw mem_image,\n      rw mem_image at yft,\n      cases yft with x hx,\n      cases hx with xt fxy,\n      use x,\n      split,\n      { apply mem_union_right,\n        exact xt, },\n      { exact fxy, }}},\nend\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nbegin\n  ext y,\n  split,\n  { rintro \u27e8x, xst, rfl\u27e9,\n    cases xst with xs xt,\n    { left,\n      exact mem_image_of_mem f xs, },\n    { right,\n      exact mem_image_of_mem f xt, }},\n  { rintro (yfs | yft),\n    { rcases yfs with \u27e8x, xs, rfl\u27e9,\n      apply mem_image_of_mem,\n      left,\n      exact xs, },\n    { rcases yft with \u27e8x, xt, rfl\u27e9,\n      apply mem_image_of_mem,\n      right,\n      exact xt, }},\nend\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nbegin\n  ext y,\n  split,\n  { rintro \u27e8x, xst, rfl\u27e9,\n    cases xst with xs xt,\n    { left,\n      use [x, xs], },\n    { right,\n      use [x, xt], }},\n  { rintro (yfs | yft),\n    { rcases yfs with \u27e8x, xs, rfl\u27e9,\n      use [x, or.inl xs], },\n    { rcases yft with \u27e8x, xt, rfl\u27e9,\n      use [x, or.inr xt], }},\nend\n\n-- 4\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nbegin\n  ext y,\n  split,\n  { rintro \u27e8x, xs | xt, rfl\u27e9,\n    { left,\n      use [x, xs], },\n    { right,\n      use [x, xt], }},\n  { rintros (\u27e8x, xs, rfl\u27e9 | \u27e8x, xt, rfl\u27e9),\n    { use [x, or.inl xs], },\n    { use [x, or.inr xt], }},\nend\n\n-- 5\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nbegin\n  ext y,\n  split,\n  { rintros \u27e8x, xs | xt, rfl\u27e9 ; finish, },\n  { rintros (\u27e8x, xs, rfl\u27e9 | \u27e8x, xt, rfl\u27e9) ; finish, },\nend\n\n-- 6\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nbegin\n  ext y,\n  split,\n  { finish, },\n  { finish, },\nend\n\n-- 7\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nbegin\n  ext y,\n  rw iff_def,\n  finish,\nend\n\n-- 8\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nby finish [ext_iff, iff_def]\n\n-- 9\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\n-- by library_search\nimage_union f s t\n<\/pre>\n<p>El c\u00f3digo de las demostraciones se encuentra en <a href=\"https:\/\/github.com\/jaalonso\/Razonando-con-Lean\/blob\/main\/src\/Imagen_de_la_union.lean\">GitHub<\/a> y puede ejecutarse con el <a href=\"https:\/\/leanprover-community.github.io\/lean-web-editor\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Razonando-con-Lean\/main\/src\/Imagen_de_la_union.lean\">Lean Web editor<\/a>.<\/p>\n<p>La construcci\u00f3n de las demostraciones se muestra en el siguiente v\u00eddeo<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/fw8BJy8PGkM\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<p><a name=\"ej2\"><\/a><\/p>\n<h3>2. Teorema de Cantor<\/h3>\n<p>Demostrar el teorema de Cantor; es decir, que no existe ninguna aplicaci\u00f3n suprayectiva de un conjunto en su conjunto potencia.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/p>\n<pre lang=\"lean\">\nimport data.set.basic\nopen function\n\nvariables {\u03b1 : Type}\n\nexample : \u2200 f : \u03b1 \u2192 set \u03b1, \u00ac surjective f :=\nsorry\n<\/pre>\n<p><!--more--><\/p>\n<p><strong>Soluciones con Lean<\/strong><\/p>\n<pre lang=\"lean\">\nimport data.set.basic\nopen function\n\nvariables {\u03b1 : Type}\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample : \u2200 f : \u03b1 \u2192 set \u03b1, \u00ac surjective f :=\nbegin\n  intros f hf,\n  let S := {i | i \u2209 f i},\n  unfold surjective at hf,\n  cases hf S with j hj,\n  by_cases j \u2208 S,\n  { dsimp at h,\n    apply h,\n    rw hj,\n    exact h, },\n  { apply h,\n    rw \u2190 hj at h,\n    exact h, },\nend\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample : \u2200 f : \u03b1 \u2192 set \u03b1, \u00ac surjective f :=\nbegin\n  intros f hf,\n  let S := {i | i \u2209 f i},\n  cases hf S with j hj,\n  by_cases j \u2208 S,\n  { apply  h,\n    rwa hj, },\n  { apply h,\n    rwa \u2190 hj at h, },\nend\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample : \u2200 f : \u03b1 \u2192 set \u03b1, \u00ac surjective f :=\nbegin\n  intros f hf,\n  let S := {i | i \u2209 f i},\n  cases hf S with j hj,\n  have h : (j \u2208 S) = (j \u2209 S), from\n    calc  (j \u2208 S)\n        = (j \u2209 f j) : set.mem_set_of_eq\n    ... = (j \u2209 S)   : congr_arg not (congr_arg (has_mem.mem j) hj),\n  exact false_of_a_eq_not_a h,\nend\n\n-- 4\u00aa demostraci\u00f3n\n-- ===============\n\nexample : \u2200 f : \u03b1 \u2192 set \u03b1, \u00ac surjective f :=\nbegin\n  intros f hf,\n  let S := {i | i \u2209 f i},\n  cases hf S with j hj,\n  have h : (j \u2208 S) = (j \u2209 S),\n  { dsimp,\n    exact congr_arg not (congr_arg (has_mem.mem j) hj), },\n  { exact false_of_a_eq_not_a (congr_arg not (congr_arg not h)), },\nend\n\n-- 5\u00aa demostraci\u00f3n\n-- ===============\n\nexample : \u2200 f : \u03b1 \u2192 set \u03b1, \u00ac surjective f :=\ncantor_surjective\n<\/pre>\n<p>El c\u00f3digo de las demostraciones se encuentra en <a href=\"https:\/\/github.com\/jaalonso\/Razonando-con-Lean\/blob\/main\/src\/Teorema_de_Cantor.lean\">GitHub<\/a> y puede ejecutarse con el <a href=\"https:\/\/leanprover-community.github.io\/lean-web-editor\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Razonando-con-Lean\/main\/src\/Teorema_de_Cantor.lean\">Lean Web editor<\/a>.<\/p>\n<p>La construcci\u00f3n de las demostraciones se muestra en el siguiente v\u00eddeo<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/Kn79deNnEhU\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Esta semana he publicado en Calculemus las soluciones de los siguientes problemas: 1. Imagen de la uni\u00f3n 2. Teorema de Cantor A continuaci\u00f3n se muestran las soluciones.<\/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\/7738"}],"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=7738"}],"version-history":[{"count":1,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/posts\/7738\/revisions"}],"predecessor-version":[{"id":7739,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/posts\/7738\/revisions\/7739"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/media?parent=7738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/categories?post=7738"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/tags?post=7738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}