        {"id":931,"date":"2022-04-30T16:15:16","date_gmt":"2022-04-30T14:15:16","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=931"},"modified":"2022-05-01T12:36:46","modified_gmt":"2022-05-01T10:36:46","slug":"imagen-inversa-de-la-interseccion","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/imagen-inversa-de-la-interseccion\/","title":{"rendered":"Imagen inversa de la intersecci\u00f3n"},"content":{"rendered":"<p>En Lean, la imagen inversa de un conjunto s (de elementos de tipo  por la funci\u00f3n f (de tipo \u03b1 \u2192 \u03b2) es el conjunto <code>f \u207b\u00b9' s<\/code> de elementos x (de tipo \u03b1) tales que <code>f x \u2208 s<\/code>.<\/p>\n<p>Demostrar que <code>f \u207b\u00b9' (u \u2229 v) = f \u207b\u00b9' u \u2229 f \u207b\u00b9' v<\/code><\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/p>\n<pre lang=\"lean\">\nimport data.set.basic\n\nopen set\n\nvariables {\u03b1 : Type*} {\u03b2 : Type*}\nvariable  f : \u03b1 \u2192 \u03b2\nvariables u v : set \u03b2\n\nexample : f \u207b\u00b9' (u \u2229 v) = f \u207b\u00b9' u \u2229 f \u207b\u00b9' v :=\nsorry\n<\/pre>\n<p><!--more--><\/p>\n<p><strong>Soluciones con Lean<\/strong><\/p>\n<pre lang=\"lean\">\nimport data.set.basic\n\nopen set\n\nvariables {\u03b1 : Type*} {\u03b2 : Type*}\nvariable  f : \u03b1 \u2192 \u03b2\nvariables u v : set \u03b2\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f \u207b\u00b9' (u \u2229 v) = f \u207b\u00b9' u \u2229 f \u207b\u00b9' v :=\nbegin\n  ext x,\n  split,\n  { intro h,\n    split,\n    { apply mem_preimage.mpr,\n      rw mem_preimage at h,\n      exact mem_of_mem_inter_left h, },\n    { apply mem_preimage.mpr,\n      rw mem_preimage at h,\n      exact mem_of_mem_inter_right h, }},\n  { intro h,\n    apply mem_preimage.mpr,\n    split,\n    { apply mem_preimage.mp,\n      exact mem_of_mem_inter_left h,},\n    { apply mem_preimage.mp,\n      exact mem_of_mem_inter_right h, }},\nend\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f \u207b\u00b9' (u \u2229 v) = f \u207b\u00b9' u \u2229 f \u207b\u00b9' v :=\nbegin\n  ext x,\n  split,\n  { intro h,\n    split,\n    { simp at *,\n      exact h.1, },\n    { simp at *,\n      exact h.2, }},\n  { intro h,\n    simp at *,\n    exact h, },\nend\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f \u207b\u00b9' (u \u2229 v) = f \u207b\u00b9' u \u2229 f \u207b\u00b9' v :=\n-- by hint\nby finish\n\n-- 4\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f \u207b\u00b9' (u \u2229 v) = f \u207b\u00b9' u \u2229 f \u207b\u00b9' v :=\n-- by library_search\npreimage_inter\n\n-- 5\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f \u207b\u00b9' (u \u2229 v) = f \u207b\u00b9' u \u2229 f \u207b\u00b9' v :=\nrfl\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_inversa_de_la_interseccion.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_inversa_de_la_interseccion.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\/av4vNL8-AJA\" 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_inversa_de_la_interseccion\nimports Main\nbegin\n\nsection \u20391\u00aa demostraci\u00f3n\u203a\n\nlemma \"f -` (u \u2229 v) = f -` u \u2229 f -` v\"\nproof (rule equalityI)\n  show \"f -` (u \u2229 v) \u2286 f -` u \u2229 f -` v\"\n  proof (rule subsetI)\n    fix x\n    assume \"x \u2208 f -` (u \u2229 v)\"\n    then have h : \"f x \u2208 u \u2229 v\"\n      by (simp only: vimage_eq)\n    have \"x \u2208 f -` u\"\n    proof -\n      have \"f x \u2208 u\"\n        using h by (rule IntD1)\n      then show \"x \u2208 f -` u\"\n        by (rule vimageI2)\n    qed\n    moreover\n    have \"x \u2208 f -` v\"\n    proof -\n      have \"f x \u2208 v\"\n        using h by (rule IntD2)\n      then show \"x \u2208 f -` v\"\n        by (rule vimageI2)\n    qed\n    ultimately show \"x \u2208 f -` u \u2229 f -` v\"\n      by (rule IntI)\n  qed\nnext\n  show \"f -` u \u2229 f -` v \u2286 f -` (u \u2229 v)\"\n  proof (rule subsetI)\n    fix x\n    assume h2 : \"x \u2208 f -` u \u2229 f -` v\"\n    have \"f x \u2208 u\"\n    proof -\n      have \"x \u2208 f -` u\"\n        using h2 by (rule IntD1)\n      then show \"f x \u2208 u\"\n        by (rule vimageD)\n    qed\n    moreover\n    have \"f x \u2208 v\"\n    proof -\n      have \"x \u2208 f -` v\"\n        using h2 by (rule IntD2)\n      then show \"f x \u2208 v\"\n        by (rule vimageD)\n    qed\n    ultimately have \"f x \u2208 u \u2229 v\"\n      by (rule IntI)\n    then show \"x \u2208 f -` (u \u2229 v)\"\n      by (rule vimageI2)\n  qed\nqed\n\nsection \u20392\u00aa demostraci\u00f3n\u203a\n\nlemma \"f -` (u \u2229 v) = f -` u \u2229 f -` v\"\nproof\n  show \"f -` (u \u2229 v) \u2286 f -` u \u2229 f -` v\"\n  proof\n    fix x\n    assume \"x \u2208 f -` (u \u2229 v)\"\n    then have h : \"f x \u2208 u \u2229 v\"\n      by simp\n    have \"x \u2208 f -` u\"\n    proof -\n      have \"f x \u2208 u\"\n        using h by simp\n      then show \"x \u2208 f -` u\"\n        by simp\n    qed\n    moreover\n    have \"x \u2208 f -` v\"\n    proof -\n      have \"f x \u2208 v\"\n        using h by simp\n      then show \"x \u2208 f -` v\"\n        by simp\n    qed\n    ultimately show \"x \u2208 f -` u \u2229 f -` v\"\n      by simp\n  qed\nnext\n  show \"f -` u \u2229 f -` v \u2286 f -` (u \u2229 v)\"\n  proof\n    fix x\n    assume h2 : \"x \u2208 f -` u \u2229 f -` v\"\n    have \"f x \u2208 u\"\n    proof -\n      have \"x \u2208 f -` u\"\n        using h2 by simp\n      then show \"f x \u2208 u\"\n        by simp\n    qed\n    moreover\n    have \"f x \u2208 v\"\n    proof -\n      have \"x \u2208 f -` v\"\n        using h2 by simp\n      then show \"f x \u2208 v\"\n        by simp\n    qed\n    ultimately have \"f x \u2208 u \u2229 v\"\n      by simp\n    then show \"x \u2208 f -` (u \u2229 v)\"\n      by simp\n  qed\nqed\n\nsection \u20393\u00aa demostraci\u00f3n\u203a\n\nlemma \"f -` (u \u2229 v) = f -` u \u2229 f -` v\"\nproof\n  show \"f -` (u \u2229 v) \u2286 f -` u \u2229 f -` v\"\n  proof\n    fix x\n    assume h1 : \"x \u2208 f -` (u \u2229 v)\"\n    have \"x \u2208 f -` u\" using h1 by simp\n    moreover\n    have \"x \u2208 f -` v\" using h1 by simp\n    ultimately show \"x \u2208 f -` u \u2229 f -` v\" by simp\n  qed\nnext\n  show \"f -` u \u2229 f -` v \u2286 f -` (u \u2229 v)\"\n  proof\n    fix x\n    assume h2 : \"x \u2208 f -` u \u2229 f -` v\"\n    have \"f x \u2208 u\" using h2 by simp\n    moreover\n    have \"f x \u2208 v\" using h2 by simp\n    ultimately have \"f x \u2208 u \u2229 v\" by simp\n    then show \"x \u2208 f -` (u \u2229 v)\" by simp\n  qed\nqed\n\nsection \u20394\u00aa demostraci\u00f3n\u203a\n\nlemma \"f -` (u \u2229 v) = f -` u \u2229 f -` v\"\n  by (simp only: vimage_Int)\n\nsection \u20395\u00aa demostraci\u00f3n\u203a\n\nlemma \"f -` (u \u2229 v) = f -` u \u2229 f -` v\"\n  by auto\n\nend\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>En Lean, la imagen inversa de un conjunto s (de elementos de tipo por la funci\u00f3n f (de tipo \u03b1 \u2192 \u03b2) es el conjunto f \u207b\u00b9&#8217; s de elementos x (de tipo \u03b1) tales que f x \u2208 s. Demostrar que f \u207b\u00b9&#8217; (u \u2229 v) = f \u207b\u00b9&#8217; u \u2229 f \u207b\u00b9&#8217; v Para ello, completar la siguiente teor\u00eda de Lean: import data.set.basic open set variables {\u03b1 : Type*} {\u03b2 : Type*} variable f : \u03b1 \u2192 \u03b2 variables u v : set \u03b2 example : f \u207b\u00b9&#8217; (u \u2229 v) = f \u207b\u00b9&#8217; u \u2229 f \u207b\u00b9&#8217; v := 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":[17],"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\/931"}],"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=931"}],"version-history":[{"count":5,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/931\/revisions"}],"predecessor-version":[{"id":938,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/931\/revisions\/938"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=931"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}