        {"id":940,"date":"2022-05-03T19:42:13","date_gmt":"2022-05-03T17:42:13","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=940"},"modified":"2022-05-04T14:19:22","modified_gmt":"2022-05-04T12:19:22","slug":"imagen-de-la-union","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/imagen-de-la-union\/","title":{"rendered":"Imagen de la uni\u00f3n"},"content":{"rendered":"<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><strong>Soluciones con Isabelle\/HOL<\/strong><\/p>\n<pre lang=\"isar\">\ntheory Imagen_de_la_union\nimports Main\nbegin\n\nsection \u20391\u00aa demostraci\u00f3n\u203a\n\nlemma \"f ` (s \u222a t) = f ` s \u222a f ` t\"\nproof (rule equalityI)\n  show \"f ` (s \u222a t) \u2286 f ` s \u222a f ` t\"\n  proof (rule subsetI)\n    fix y\n    assume \"y \u2208 f ` (s \u222a t)\"\n    then show \"y \u2208 f ` s \u222a f ` t\"\n    proof (rule imageE)\n      fix x\n      assume \"y = f x\"\n      assume \"x \u2208 s \u222a t\"\n      then show \"y \u2208 f ` s \u222a f ` t\"\n      proof (rule UnE)\n        assume \"x \u2208 s\"\n        with \u2039y = f x\u203a have \"y \u2208 f ` s\"\n          by (simp only: image_eqI)\n        then show \"y \u2208 f ` s \u222a f ` t\"\n          by (rule UnI1)\n      next\n        assume \"x \u2208 t\"\n        with \u2039y = f x\u203a have \"y \u2208 f ` t\"\n          by (simp only: image_eqI)\n        then show \"y \u2208 f ` s \u222a f ` t\"\n          by (rule UnI2)\n      qed\n    qed\n  qed\nnext\n  show \"f ` s \u222a f ` t \u2286 f ` (s \u222a t)\"\n  proof (rule subsetI)\n    fix y\n    assume \"y \u2208 f ` s \u222a f ` t\"\n    then show \"y \u2208 f ` (s \u222a t)\"\n    proof (rule UnE)\n      assume \"y \u2208 f ` s\"\n      then show \"y \u2208 f ` (s \u222a t)\"\n      proof (rule imageE)\n        fix x\n        assume \"y = f x\"\n        assume \"x \u2208 s\"\n        then have \"x \u2208 s \u222a t\"\n          by (rule UnI1)\n        with \u2039y = f x\u203a show \"y \u2208 f ` (s \u222a t)\"\n          by (simp only: image_eqI)\n      qed\n    next\n      assume \"y \u2208 f ` t\"\n      then show \"y \u2208 f ` (s \u222a t)\"\n      proof (rule imageE)\n        fix x\n        assume \"y = f x\"\n        assume \"x \u2208 t\"\n        then have \"x \u2208 s \u222a t\"\n          by (rule UnI2)\n        with \u2039y = f x\u203a show \"y \u2208 f ` (s \u222a t)\"\n          by (simp only: image_eqI)\n      qed\n    qed\n  qed\nqed\n\nsection \u20392\u00aa demostraci\u00f3n\u203a\n\nlemma \"f ` (s \u222a t) = f ` s \u222a f ` t\"\nproof\n  show \"f ` (s \u222a t) \u2286 f ` s \u222a f ` t\"\n  proof\n    fix y\n    assume \"y \u2208 f ` (s \u222a t)\"\n    then show \"y \u2208 f ` s \u222a f ` t\"\n    proof\n      fix x\n      assume \"y = f x\"\n      assume \"x \u2208 s \u222a t\"\n      then show \"y \u2208 f ` s \u222a f ` t\"\n      proof\n        assume \"x \u2208 s\"\n        with \u2039y = f x\u203a have \"y \u2208 f ` s\"\n          by simp\n        then show \"y \u2208 f ` s \u222a f ` t\"\n          by simp\n      next\n        assume \"x \u2208 t\"\n        with \u2039y = f x\u203a have \"y \u2208 f ` t\"\n          by simp\n        then show \"y \u2208 f ` s \u222a f ` t\"\n          by simp\n      qed\n    qed\n  qed\nnext\n  show \"f ` s \u222a f ` t \u2286 f ` (s \u222a t)\"\n  proof\n    fix y\n    assume \"y \u2208 f ` s \u222a f ` t\"\n    then show \"y \u2208 f ` (s \u222a t)\"\n    proof\n      assume \"y \u2208 f ` s\"\n      then show \"y \u2208 f ` (s \u222a t)\"\n      proof\n        fix x\n        assume \"y = f x\"\n        assume \"x \u2208 s\"\n        then have \"x \u2208 s \u222a t\"\n          by simp\n        with \u2039y = f x\u203a show \"y \u2208 f ` (s \u222a t)\"\n          by simp\n      qed\n    next\n      assume \"y \u2208 f ` t\"\n      then show \"y \u2208 f ` (s \u222a t)\"\n      proof\n        fix x\n        assume \"y = f x\"\n        assume \"x \u2208 t\"\n        then have \"x \u2208 s \u222a t\"\n          by simp\n        with \u2039y = f x\u203a show \"y \u2208 f ` (s \u222a t)\"\n          by simp\n      qed\n    qed\n  qed\nqed\n\nsection \u20393\u00aa demostraci\u00f3n\u203a\n\nlemma \"f ` (s \u222a t) = f ` s \u222a f ` t\"\n  by (simp only: image_Un)\n\nsection \u20394\u00aa demostraci\u00f3n\u203a\n\nlemma \"f ` (s \u222a t) = f ` s \u222a f ` t\"\n  by auto\n\nend\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>En Lean, la imagen de un conjunto s por una funci\u00f3n f se representa por f \u00bb s; es decir, f \u00bb s = {y | \u2203 x, x \u2208 s \u2227 f x = y} Demostrar que f \u00bb (s \u222a t) = f \u00bb s \u222a f \u00bb t Para ello, completar la siguiente teor\u00eda de Lean: import data.set.basic import tactic open set variables {\u03b1 : Type*} {\u03b2 : Type*} variable f : \u03b1 \u2192 \u03b2 variables s t : set \u03b1 example : f \u00bb (s \u222a t) = f \u00bb s \u222a f \u00bb t := 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":[282],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/940"}],"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=940"}],"version-history":[{"count":2,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/940\/revisions"}],"predecessor-version":[{"id":942,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/940\/revisions\/942"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}