        {"id":483,"date":"2021-06-19T06:00:28","date_gmt":"2021-06-19T04:00:28","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=483"},"modified":"2021-06-13T17:42:08","modified_gmt":"2021-06-13T15:42:08","slug":"interseccion-con-la-imagen","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/interseccion-con-la-imagen\/","title":{"rendered":"Intersecci\u00f3n con la imagen"},"content":{"rendered":"<p>Demostrar que<\/p>\n<pre lang=\"text\">\n   f[s] \u2229 v = f[s \u2229 f\u207b\u00b9[v]]\n<\/pre>\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\nvariable  s : set \u03b1\nvariable  v : set \u03b2\n\nexample : (f '' s) \u2229 v = f '' (s \u2229 f \u207b\u00b9' v) :=\nsorry\n<\/pre>\n<p>[expand title=\u00bbSoluciones con Lean\u00bb]<\/p>\n<pre lang=\"lean\">\r\nimport data.set.basic\r\nimport tactic\r\n\r\nopen set\r\n\r\nvariables {\u03b1 : Type*} {\u03b2 : Type*}\r\nvariable  f : \u03b1 \u2192 \u03b2\r\nvariable  s : set \u03b1\r\nvariable  v : set \u03b2\r\n\r\n-- 1\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample : (f '' s) \u2229 v = f '' (s \u2229 f \u207b\u00b9' v) :=\r\nbegin\r\n  ext y,\r\n  split,\r\n  { intro hy,\r\n    cases hy with hyfs yv,\r\n    cases hyfs with x hx,\r\n    cases hx with xs fxy,\r\n    use x,\r\n    split,\r\n    { split,\r\n      { exact xs, },\r\n      { rw mem_preimage,\r\n        rw fxy,\r\n        exact yv, }},\r\n    { exact fxy, }},\r\n  { intro hy,\r\n    cases hy with x hx,\r\n    split,\r\n    { use x,\r\n      split,\r\n      { exact hx.1.1, },\r\n      { exact hx.2, }},\r\n    { cases hx with hx1 fxy,\r\n      rw \u2190 fxy,\r\n      rw \u2190 mem_preimage,\r\n      exact hx1.2, }},\r\nend\r\n\r\n-- 2\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample : (f '' s) \u2229 v = f '' (s \u2229 f \u207b\u00b9' v) :=\r\nbegin\r\n  ext y,\r\n  split,\r\n  { rintros \u27e8\u27e8x, xs, fxy\u27e9, yv\u27e9,\r\n    use x,\r\n    split,\r\n    { split,\r\n      { exact xs, },\r\n      { rw mem_preimage,\r\n        rw fxy,\r\n        exact yv, }},\r\n    { exact fxy, }},\r\n  { rintros \u27e8x, \u27e8xs, xv\u27e9, fxy\u27e9,\r\n    split,\r\n    { use [x, xs, fxy], },\r\n    { rw \u2190 fxy,\r\n      rw \u2190 mem_preimage,\r\n      exact xv, }},\r\nend\r\n\r\n-- 3\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample : (f '' s) \u2229 v = f '' (s \u2229 f \u207b\u00b9' v) :=\r\nbegin\r\n  ext y,\r\n  split,\r\n  { rintros \u27e8\u27e8x, xs, fxy\u27e9, yv\u27e9,\r\n    finish, },\r\n  { rintros \u27e8x, \u27e8xs, xv\u27e9, fxy\u27e9,\r\n    finish, },\r\nend\r\n\r\n-- 4\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample : (f '' s) \u2229 v = f '' (s \u2229 f \u207b\u00b9' v) :=\r\nby ext ; split ; finish\r\n\r\n-- 5\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample : (f '' s) \u2229 v = f '' (s \u2229 f \u207b\u00b9' v) :=\r\nby finish [ext_iff, iff_def]\r\n\r\n-- 6\u00aa demostraci\u00f3n\r\n-- ===============\r\n\r\nexample : (f '' s) \u2229 v = f '' (s \u2229 f \u207b\u00b9' v) :=\r\n(image_inter_preimage f s v).symm\r\n<\/pre>\n<p>Se puede interactuar con la prueba anterior en <a href=\"https:\/\/www.cs.us.es\/~jalonso\/lean-web-editor\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus\/main\/src\/Interseccion_con_la_imagen.lean\" rel=\"noopener noreferrer\" target=\"_blank\">esta sesi\u00f3n con Lean<\/a>,<\/p>\n<p>En los comentarios se pueden escribir otras soluciones, escribiendo el c\u00f3digo entre una l\u00ednea con &#60;pre lang=&quot;isar&quot;&#62; y otra con &#60;\/pre&#62;<br \/>\n[\/expand]<\/p>\n<p>[expand title=\u00bbSoluciones con Isabelle\/HOL\u00bb]<\/p>\n<pre lang=\"isar\">\r\ntheory Interseccion_con_la_imagen\r\nimports Main\r\nbegin\r\n\r\n(* 1\u00aa demostraci\u00f3n *)\r\n\r\nlemma \"(f ` s) \u2229 v = f ` (s \u2229 f -` v)\"\r\nproof (rule equalityI)\r\n  show \"(f ` s) \u2229 v \u2286 f ` (s \u2229 f -` v)\"\r\n  proof (rule subsetI)\r\n    fix y\r\n    assume \"y \u2208 (f ` s) \u2229 v\"\r\n    then show \"y \u2208 f ` (s \u2229 f -` v)\"\r\n    proof (rule IntE)\r\n      assume \"y \u2208 v\"\r\n      assume \"y \u2208 f ` s\"\r\n      then show \"y \u2208 f ` (s \u2229 f -` v)\"\r\n      proof (rule imageE)\r\n        fix x\r\n        assume \"x \u2208 s\"\r\n        assume \"y = f x\"\r\n        then have \"f x \u2208 v\"\r\n          using \u2039y \u2208 v\u203a by (rule subst)\r\n        then have \"x \u2208 f -` v\"\r\n          by (rule vimageI2)\r\n        with \u2039x \u2208 s\u203a have \"x \u2208 s \u2229 f -` v\"\r\n          by (rule IntI)\r\n        then have \"f x \u2208 f ` (s \u2229 f -` v)\"\r\n          by (rule imageI)\r\n        with \u2039y = f x\u203a show \"y \u2208 f ` (s \u2229 f -` v)\"\r\n          by (rule ssubst)\r\n      qed\r\n    qed\r\n  qed\r\nnext\r\n  show \"f ` (s \u2229 f -` v) \u2286 (f ` s) \u2229 v\"\r\n  proof (rule subsetI)\r\n    fix y\r\n    assume \"y \u2208 f ` (s \u2229 f -` v)\"\r\n    then show \"y \u2208 (f ` s) \u2229 v\"\r\n    proof (rule imageE)\r\n      fix x\r\n      assume \"y = f x\"\r\n      assume hx : \"x \u2208 s \u2229 f -` v\"\r\n      have \"y \u2208 f ` s\"\r\n      proof -\r\n        have \"x \u2208 s\"\r\n          using hx by (rule IntD1)\r\n        then have \"f x \u2208 f ` s\"\r\n          by (rule imageI)\r\n        with \u2039y = f x\u203a show \"y \u2208 f ` s\"\r\n          by (rule ssubst)\r\n      qed\r\n      moreover\r\n      have \"y \u2208 v\"\r\n      proof -\r\n        have \"x \u2208 f -` v\"\r\n          using hx by (rule IntD2)\r\n        then have \"f x \u2208 v\"\r\n          by (rule vimageD)\r\n        with \u2039y = f x\u203a show \"y \u2208 v\"\r\n          by (rule ssubst)\r\n      qed\r\n      ultimately show \"y \u2208 (f ` s) \u2229 v\"\r\n        by (rule IntI)\r\n    qed\r\n  qed\r\nqed\r\n\r\n(* 2\u00aa demostraci\u00f3n *)\r\n\r\nlemma \"(f ` s) \u2229 v = f ` (s \u2229 f -` v)\"\r\nproof\r\n  show \"(f ` s) \u2229 v \u2286 f ` (s \u2229 f -` v)\"\r\n  proof\r\n    fix y\r\n    assume \"y \u2208 (f ` s) \u2229 v\"\r\n    then show \"y \u2208 f ` (s \u2229 f -` v)\"\r\n    proof\r\n      assume \"y \u2208 v\"\r\n      assume \"y \u2208 f ` s\"\r\n      then show \"y \u2208 f ` (s \u2229 f -` v)\"\r\n      proof\r\n        fix x\r\n        assume \"x \u2208 s\"\r\n        assume \"y = f x\"\r\n        then have \"f x \u2208 v\" using \u2039y \u2208 v\u203a by simp\r\n        then have \"x \u2208 f -` v\" by simp\r\n        with \u2039x \u2208 s\u203a have \"x \u2208 s \u2229 f -` v\" by simp\r\n        then have \"f x \u2208 f ` (s \u2229 f -` v)\" by simp\r\n        with \u2039y = f x\u203a show \"y \u2208 f ` (s \u2229 f -` v)\" by simp\r\n      qed\r\n    qed\r\n  qed\r\nnext\r\n  show \"f ` (s \u2229 f -` v) \u2286 (f ` s) \u2229 v\"\r\n  proof\r\n    fix y\r\n    assume \"y \u2208 f ` (s \u2229 f -` v)\"\r\n    then show \"y \u2208 (f ` s) \u2229 v\"\r\n    proof\r\n      fix x\r\n      assume \"y = f x\"\r\n      assume hx : \"x \u2208 s \u2229 f -` v\"\r\n      have \"y \u2208 f ` s\"\r\n      proof -\r\n        have \"x \u2208 s\" using hx by simp\r\n        then have \"f x \u2208 f ` s\" by simp\r\n        with \u2039y = f x\u203a show \"y \u2208 f ` s\" by simp\r\n      qed\r\n      moreover\r\n      have \"y \u2208 v\"\r\n      proof -\r\n        have \"x \u2208 f -` v\" using hx by simp\r\n        then have \"f x \u2208 v\" by simp\r\n        with \u2039y = f x\u203a show \"y \u2208 v\" by simp\r\n      qed\r\n      ultimately show \"y \u2208 (f ` s) \u2229 v\" by simp\r\n    qed\r\n  qed\r\nqed\r\n\r\n(* 2\u00aa demostraci\u00f3n *)\r\n\r\nlemma \"(f ` s) \u2229 v = f ` (s \u2229 f -` v)\"\r\nproof\r\n  show \"(f ` s) \u2229 v \u2286 f ` (s \u2229 f -` v)\"\r\n  proof\r\n    fix y\r\n    assume \"y \u2208 (f ` s) \u2229 v\"\r\n    then show \"y \u2208 f ` (s \u2229 f -` v)\"\r\n    proof\r\n      assume \"y \u2208 v\"\r\n      assume \"y \u2208 f ` s\"\r\n      then show \"y \u2208 f ` (s \u2229 f -` v)\"\r\n      proof\r\n        fix x\r\n        assume \"x \u2208 s\"\r\n        assume \"y = f x\"\r\n        then show \"y \u2208 f ` (s \u2229 f -` v)\"\r\n          using \u2039x \u2208 s\u203a \u2039y \u2208 v\u203a by simp\r\n      qed\r\n    qed\r\n  qed\r\nnext\r\n  show \"f ` (s \u2229 f -` v) \u2286 (f ` s) \u2229 v\"\r\n  proof\r\n    fix y\r\n    assume \"y \u2208 f ` (s \u2229 f -` v)\"\r\n    then show \"y \u2208 (f ` s) \u2229 v\"\r\n    proof\r\n      fix x\r\n      assume \"y = f x\"\r\n      assume hx : \"x \u2208 s \u2229 f -` v\"\r\n      then have \"y \u2208 f ` s\" using \u2039y = f x\u203a by simp\r\n      moreover\r\n      have \"y \u2208 v\" using hx \u2039y = f x\u203a by simp\r\n      ultimately show \"y \u2208 (f ` s) \u2229 v\" by simp\r\n    qed\r\n  qed\r\nqed\r\n\r\n(* 4\u00aa demostraci\u00f3n *)\r\n\r\nlemma \"(f ` s) \u2229 v = f ` (s \u2229 f -` v)\"\r\n  by auto\r\n\r\nend\r\n<\/pre>\n<p>En los comentarios se pueden escribir otras soluciones, escribiendo el c\u00f3digo entre una l\u00ednea con &#60;pre lang=&quot;isar&quot;&#62; y otra con &#60;\/pre&#62;<br \/>\n[\/expand]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Demostrar que f[s] \u2229 v = f[s \u2229 f\u207b\u00b9[v]] 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 variable s : set \u03b1 variable v : set \u03b2 example : (f \u00bb s) \u2229 v = f \u00bb (s \u2229 f \u207b\u00b9&#8217; v) := sorry [expand title=\u00bbSoluciones con Lean\u00bb] import data.set.basic import tactic open set variables {\u03b1 : Type*} {\u03b2 : Type*} variable f : \u03b1 \u2192 \u03b2 variable s : set \u03b1 variable v : set \u03b2 &#8212; 1\u00aa demostraci\u00f3n &#8212; =============== example : (f \u00bb s) \u2229 v = f \u00bb (s \u2229 f \u207b\u00b9&#8217; v) := begin ext y, split, { intro hy, cases&#8230;<\/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":[7],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/483"}],"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=483"}],"version-history":[{"count":1,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/483\/revisions"}],"predecessor-version":[{"id":484,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/483\/revisions\/484"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}