        {"id":2334,"date":"2024-03-13T21:00:52","date_gmt":"2024-03-13T19:00:52","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=2334"},"modified":"2024-03-13T21:02:07","modified_gmt":"2024-03-13T19:02:07","slug":"13-mar-24","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/13-mar-24\/","title":{"rendered":"f[s \u222a t] = f[s] \u222a f[t]"},"content":{"rendered":"\n<p>En Lean4, la imagen de un conjunto s por una funci\u00f3n f se representa por <code>f '' s<\/code>; es decir,<\/p>\n<pre lang=\"lean\">\n   f '' s = {y | \u2203 x, x \u2208 s \u2227 f x = y}\n<\/pre>\n<p>Demostrar con Lean4 que<\/p>\n<pre lang=\"lean\">\n   f '' (s \u222a t) = f '' s \u222a f '' t\n<\/pre>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport Mathlib.Data.Set.Function\nvariable {\u03b1 \u03b2 : Type _}\nvariable (f : \u03b1 \u2192 \u03b2)\nvariable (s t : Set \u03b1)\nopen Set\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nby sorry\n<\/pre>\n<p><!--more--><\/p>\n<h2>1. Demostraci\u00f3n en lenguaje natural<\/h2>\n<p>Tenemos que demostrar, para todo &#92;(y&#92;), que<br \/>\n&#92;[ y \u2208 f[s \u222a t] \u2194 y \u2208 f[s] \u222a f[t] &#92;]<br \/>\nLo haremos mediante la siguiente cadena de equivalencias<br \/>\n&#92;begin{align}<br \/>\n   y \u2208 f[s \u222a t] &amp;\u2194 (\u2203x)(x \u2208 s \u222a t \u2227 f x = y) &#92;&#92;<br \/>\n                &amp;\u2194 (\u2203x)((x \u2208 s \u2228 x \u2208 t) \u2227 f x = y) &#92;&#92;<br \/>\n                &amp;\u2194 (\u2203x)((x \u2208 s \u2227 f x = y) \u2228 (x \u2208 t \u2227 f x = y)) &#92;&#92;<br \/>\n                &amp;\u2194 (\u2203x)(x \u2208 s \u2227 f x = y) \u2228 (\u2203x)(x \u2208 t \u2227 f x = y) &#92;&#92;<br \/>\n                &amp;\u2194 y \u2208 f[s] \u2228 y \u2208 f[t] &#92;&#92;<br \/>\n                &amp;\u2194 y \u2208 f[s] \u222a f[t]<br \/>\n&#92;end{align}<\/p>\n<h2>2. Demostraciones con Lean4<\/h2>\n<pre lang=\"lean\">\nimport Mathlib.Data.Set.Function\n\nvariable {\u03b1 \u03b2 : Type _}\nvariable (f : \u03b1 \u2192 \u03b2)\nvariable (s t : Set \u03b1)\n\nopen Set\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nby\n  ext y\n  -- y : \u03b2\n  -- \u22a2 y \u2208 f '' (s \u222a t) \u2194 y \u2208 f '' s \u222a f '' t\n  calc y \u2208 f '' (s \u222a t)\n     \u2194 \u2203 x, x \u2208 s \u222a t \u2227 f x = y :=\n         by simp only [mem_image]\n   _ \u2194 \u2203 x, (x \u2208 s \u2228 x \u2208 t) \u2227 f x = y :=\n         by simp only [mem_union]\n   _ \u2194 \u2203 x, (x \u2208 s \u2227 f x = y) \u2228 (x \u2208 t \u2227 f x = y) :=\n         by simp only [or_and_right]\n   _ \u2194 (\u2203 x, x \u2208 s \u2227 f x = y) \u2228 (\u2203 x, x \u2208 t \u2227 f x = y) :=\n         by simp only [exists_or]\n   _ \u2194 y \u2208 f '' s \u2228 y \u2208 f '' t :=\n         by simp only [mem_image]\n   _ \u2194 y \u2208 f '' s \u222a f '' t :=\n         by simp only [mem_union]\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nby\n  ext y\n  -- y : \u03b2\n  -- \u22a2 y \u2208 f '' (s \u222a t) \u2194 y \u2208 f '' s \u222a f '' t\n  constructor\n  . -- \u22a2 y \u2208 f '' (s \u222a t) \u2192 y \u2208 f '' s \u222a f '' t\n    intro h\n    -- h : y \u2208 f '' (s \u222a t)\n    -- \u22a2 y \u2208 f '' s \u222a f '' t\n    rw [mem_image] at h\n    -- h : \u2203 x, x \u2208 s \u222a t \u2227 f x = y\n    rcases h with \u27e8x, hx\u27e9\n    -- x : \u03b1\n    -- hx : x \u2208 s \u222a t \u2227 f x = y\n    rcases hx with \u27e8xst, fxy\u27e9\n    -- xst : x \u2208 s \u222a t\n    -- fxy : f x = y\n    rw [\u2190fxy]\n    -- \u22a2 f x \u2208 f '' s \u222a f '' t\n    rw [mem_union] at xst\n    -- xst : x \u2208 s \u2228 x \u2208 t\n    rcases xst with (xs | xt)\n    . -- xs : x \u2208 s\n      apply mem_union_left\n      -- \u22a2 f x \u2208 f '' s\n      apply mem_image_of_mem\n      -- \u22a2 x \u2208 s\n      exact xs\n    . -- xt : x \u2208 t\n      apply mem_union_right\n      -- \u22a2 f x \u2208 f '' t\n      apply mem_image_of_mem\n      -- \u22a2 x \u2208 t\n      exact xt\n  . -- \u22a2 y \u2208 f '' s \u222a f '' t \u2192 y \u2208 f '' (s \u222a t)\n    intro h\n    -- h : y \u2208 f '' s \u222a f '' t\n    -- \u22a2 y \u2208 f '' (s \u222a t)\n    rw [mem_union] at h\n    -- h : y \u2208 f '' s \u2228 y \u2208 f '' t\n    rcases h with (yfs | yft)\n    . -- yfs : y \u2208 f '' s\n      rw [mem_image]\n      -- \u22a2 \u2203 x, x \u2208 s \u222a t \u2227 f x = y\n      rw [mem_image] at yfs\n      -- yfs : \u2203 x, x \u2208 s \u2227 f x = y\n      rcases yfs with \u27e8x, hx\u27e9\n      -- x : \u03b1\n      -- hx : x \u2208 s \u2227 f x = y\n      rcases hx with \u27e8xs, fxy\u27e9\n      -- xs : x \u2208 s\n      -- fxy : f x = y\n      use x\n      -- \u22a2 x \u2208 s \u222a t \u2227 f x = y\n      constructor\n      . -- \u22a2 x \u2208 s \u222a t\n        apply mem_union_left\n        -- \u22a2 x \u2208 s\n        exact xs\n      . -- \u22a2 f x = y\n        exact fxy\n    . -- yft : y \u2208 f '' t\n      rw [mem_image]\n      -- \u22a2 \u2203 x, x \u2208 s \u222a t \u2227 f x = y\n      rw [mem_image] at yft\n      -- yft : \u2203 x, x \u2208 t \u2227 f x = y\n      rcases yft with \u27e8x, hx\u27e9\n      -- x : \u03b1\n      -- hx : x \u2208 t \u2227 f x = y\n      rcases hx with \u27e8xt, fxy\u27e9\n      -- xt : x \u2208 t\n      -- fxy : f x = y\n      use x\n      -- \u22a2 x \u2208 s \u222a t \u2227 f x = y\n      constructor\n      . -- \u22a2 x \u2208 s \u222a t\n        apply mem_union_right\n        -- \u22a2 x \u2208 t\n        exact xt\n      . -- \u22a2 f x = y\n        exact fxy\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nby\n  ext y\n  -- y : \u03b2\n  -- \u22a2 y \u2208 f '' (s \u222a t) \u2194 y \u2208 f '' s \u222a f '' t\n  constructor\n  . -- \u22a2 y \u2208 f '' (s \u222a t) \u2192 y \u2208 f '' s \u222a f '' t\n    rintro \u27e8x, xst, rfl\u27e9\n    -- x : \u03b1\n    -- xst : x \u2208 s \u222a t\n    -- \u22a2 f x \u2208 f '' s \u222a f '' t\n    rcases xst with (xs | xt)\n    . -- xs : x \u2208 s\n      left\n      -- \u22a2 f x \u2208 f '' s\n      exact mem_image_of_mem f xs\n    . -- xt : x \u2208 t\n      right\n      -- \u22a2 f x \u2208 f '' t\n      exact mem_image_of_mem f xt\n  . -- \u22a2 y \u2208 f '' s \u222a f '' t \u2192 y \u2208 f '' (s \u222a t)\n    rintro (yfs | yft)\n    . -- yfs : y \u2208 f '' s\n      rcases yfs with \u27e8x, xs, rfl\u27e9\n      -- x : \u03b1\n      -- xs : x \u2208 s\n      -- \u22a2 f x \u2208 f '' (s \u222a t)\n      apply mem_image_of_mem\n      -- \u22a2 x \u2208 s \u222a t\n      left\n      -- \u22a2 x \u2208 s\n      exact xs\n    . -- yft : y \u2208 f '' t\n      rcases yft with \u27e8x, xt, rfl\u27e9\n      -- x : \u03b1\n      -- xs : x \u2208 s\n      -- \u22a2 f x \u2208 f '' (s \u222a t)\n      apply mem_image_of_mem\n      -- \u22a2 x \u2208 s \u222a t\n      right\n      -- \u22a2 x \u2208 t\n      exact xt\n\n-- 4\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nby\n  ext y\n  -- y : \u03b2\n  -- \u22a2 y \u2208 f '' (s \u222a t) \u2194 y \u2208 f '' s \u222a f '' t\n  constructor\n  . -- \u22a2 y \u2208 f '' (s \u222a t) \u2192 y \u2208 f '' s \u222a f '' t\n    rintro \u27e8x, xst, rfl\u27e9\n    -- x : \u03b1\n    -- xst : x \u2208 s \u222a t\n    -- \u22a2 f x \u2208 f '' s \u222a f '' t\n    rcases xst with (xs | xt)\n    . -- xs : x \u2208 s\n      left\n      -- \u22a2 f x \u2208 f '' s\n      use x, xs\n    . -- xt : x \u2208 t\n      right\n      -- \u22a2 f x \u2208 f '' t\n      use x, xt\n  . rintro (yfs | yft)\n    . -- yfs : y \u2208 f '' s\n      rcases yfs with \u27e8x, xs, rfl\u27e9\n      -- x : \u03b1\n      -- xs : x \u2208 s\n      -- \u22a2 f x \u2208 f '' (s \u222a t)\n      use x, Or.inl xs\n    . -- yft : y \u2208 f '' t\n      rcases yft with \u27e8x, xt, rfl\u27e9\n      -- x : \u03b1\n      -- xt : x \u2208 t\n      -- \u22a2 f x \u2208 f '' (s \u222a t)\n      use x, Or.inr xt\n\n-- 5\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nby\n  ext y\n  -- y : \u03b2\n  -- \u22a2 y \u2208 f '' (s \u222a t) \u2194 y \u2208 f '' s \u222a f '' t\n  constructor\n  . -- \u22a2 y \u2208 f '' (s \u222a t) \u2192 y \u2208 f '' s \u222a f '' t\n    rintro \u27e8x, xs | xt, rfl\u27e9\n    . -- x : \u03b1\n      -- xs : x \u2208 s\n      -- \u22a2 f x \u2208 f '' s \u222a f '' t\n      left\n      -- \u22a2 f x \u2208 f '' s\n      use x, xs\n    . -- x : \u03b1\n      -- xt : x \u2208 t\n      -- \u22a2 f x \u2208 f '' s \u222a f '' t\n      right\n      -- \u22a2 f x \u2208 f '' t\n      use x, xt\n  . -- \u22a2 y \u2208 f '' s \u222a f '' t \u2192 y \u2208 f '' (s \u222a t)\n    rintro (\u27e8x, xs, rfl\u27e9 | \u27e8x, xt, rfl\u27e9)\n    . -- x : \u03b1\n      -- xs : x \u2208 s\n      -- \u22a2 f x \u2208 f '' (s \u222a t)\n      use x, Or.inl xs\n    . -- x : \u03b1\n      -- xt : x \u2208 t\n      -- \u22a2 f x \u2208 f '' (s \u222a t)\n      use x, Or.inr xt\n\n-- 6\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nby\n  ext y\n  -- y : \u03b2\n  -- \u22a2 y \u2208 f '' (s \u222a t) \u2194 y \u2208 f '' s \u222a f '' t\n  constructor\n  . -- \u22a2 y \u2208 f '' (s \u222a t) \u2192 y \u2208 f '' s \u222a f '' t\n    aesop\n  . -- \u22a2 y \u2208 f '' s \u222a f '' t \u2192 y \u2208 f '' (s \u222a t)\n    aesop\n\n-- 7\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nby\n  ext y\n  constructor <;> aesop\n\n-- 8\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nby\n  ext y\n  -- y : \u03b2\n  -- \u22a2 y \u2208 f '' (s \u222a t) \u2194 y \u2208 f '' s \u222a f '' t\n  rw [iff_def]\n  -- \u22a2 (y \u2208 f '' (s \u222a t) \u2192 y \u2208 f '' s \u222a f '' t) \u2227 (y \u2208 f '' s \u222a f '' t \u2192 y \u2208 f '' (s \u222a t))\n  aesop\n\n-- 9\u00aa demostraci\u00f3n\n-- ===============\n\nexample : f '' (s \u222a t) = f '' s \u222a f '' t :=\nimage_union f s t\n\n-- Lemas usados\n-- ============\n\n-- variable (x : \u03b1)\n-- variable (y : \u03b2)\n-- variable (a b c : Prop)\n-- variable (p q : \u03b1 \u2192 Prop)\n-- #check (Or.inl : a \u2192 a \u2228 b)\n-- #check (Or.inr : b \u2192 a \u2228 b)\n-- #check (exists_or : (\u2203 x, p x \u2228 q x) \u2194 (\u2203 x, p x) \u2228 \u2203 x, q x)\n-- #check (iff_def : (a \u2194 b) \u2194 (a \u2192 b) \u2227 (b \u2192 a))\n-- #check (image_union f s t : f '' (s \u222a t) = f '' s \u222a f '' t)\n-- #check (mem_image f s y : (y \u2208 f '' s \u2194 \u2203 (x : \u03b1), x \u2208 s \u2227 f x = y))\n-- #check (mem_image_of_mem  f : x \u2208 s \u2192 f x \u2208 f '' s)\n-- #check (mem_union x s t : x \u2208 s \u222a t \u2194 x \u2208 s \u2228 x \u2208 t)\n-- #check (mem_union_left t : x \u2208 s \u2192 x \u2208 s \u222a t)\n-- #check (mem_union_right s : x \u2208 t \u2192 x \u2208 s \u222a t)\n-- #check (or_and_right : (a \u2228 b) \u2227 c \u2194 a \u2227 c \u2228 b \u2227 c)\n<\/pre>\n<p>Se puede interactuar con las demostraciones anteriores en <a href=\"https:\/\/live.lean-lang.org\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus2\/main\/src\/Imagen_de_la_union.lean\" rel=\"noopener noreferrer\" target=\"_blank\">Lean 4 Web<\/a>.<\/p>\n<h2>3. Demostraciones con Isabelle\/HOL<\/h2>\n<pre lang=\"isar\">\ntheory Imagen_de_la_union\nimports Main\nbegin\n\n(* 1\u00aa demostraci\u00f3n *)\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\n(* 2\u00aa demostraci\u00f3n *)\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\n(* 3\u00aa demostraci\u00f3n *)\nlemma \"f ` (s \u222a t) = f ` s \u222a f ` t\"\n  by (simp only: image_Un)\n\n(* 4\u00aa demostraci\u00f3n *)\nlemma \"f ` (s \u222a t) = f ` s \u222a f ` t\"\n  by auto\n\nend\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Demostrar con Lean4 e Isabelle\/HOL que f[s \u222a t] = f[s] \u222a f[t].<\/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":"default","_kad_post_title":"default","_kad_post_layout":"default","_kad_post_sidebar_id":"","_kad_post_content_style":"default","_kad_post_vertical_padding":"default","_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":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2334"}],"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=2334"}],"version-history":[{"count":3,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2334\/revisions"}],"predecessor-version":[{"id":2337,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2334\/revisions\/2337"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=2334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=2334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=2334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}